Skip to content

Instantly share code, notes, and snippets.

@bouk
Created January 5, 2013 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bouk/4461205 to your computer and use it in GitHub Desktop.
Save bouk/4461205 to your computer and use it in GitHub Desktop.
Brainfuck to C
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