Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

eerui

Name: Anonymous 2010-09-16 22:38

ITT:
We write different ways to produce 'hello world' in the shell
language : c++
no syntax errors, and no copying others work. I'll start with something simple

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

Name: Anonymous 2010-09-17 14:59

import sys

def null_ord(ch):
    if ch > 0:
        return ord(c)
    else:
        return 0

def brainfuck(code):
    indent = 0
    pycode = ''
    pt = 0
    ta = [0] * 32767
    for i in code:
        tab = indent * 4 * ' '
        if i == '>': # Move right
            pycode += tab + 'pt += 1'
        elif i == '<': # Move left
            pycode += tab + 'pt -= 1'
        elif i == '+': # Increment cell
            pycode += tab + 'ta[pt] += 1'
        elif i == '-': # Decrement cell
            pycode += tab + 'ta[pt] -= 1'
        elif i == '[': # Start loop
            pycode += tab + 'while ta[pt]:'
            indent += 1
        elif i == ']': # End loop
            indent -= 1
        elif i == ',': # Read STDIN
            pycode += tab + 'ta[pt] = null_ord(sys.stdin.read(1))'
        elif i == '.': # Write STDOUT
            pycode += tab + 'sys.stdout.write(chr(ta[pt]))'
        else: # Comment
            continue
        pycode += '\n'
    exec pycode
    print

brainfuck('>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.')

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List