Created
January 5, 2013 11:57
-
-
Save bouk/4461205 to your computer and use it in GitHub Desktop.
Brainfuck to C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapping = { | |
'>': '++p;', | |
'<': '--p;', | |
'+': '++*p;', | |
'-': '--*p;', | |
'.': 'putchar(*p);', | |
',': '*p=getchar();', | |
'[': 'while (*p) {', | |
']': '}' | |
} | |
print "#include <cstdio>" | |
print "int main(){", | |
print "char a[30000];", | |
print "char *p = a;", | |
for line in open('LostKng.b'): | |
for char in line: | |
print mapping.get(char, ''), | |
print "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment