Skip to content

Instantly share code, notes, and snippets.

@herczy
Created September 9, 2011 21:38
Show Gist options
  • Select an option

  • Save herczy/1207404 to your computer and use it in GitHub Desktop.

Select an option

Save herczy/1207404 to your computer and use it in GitHub Desktop.
print '#include <stdio.h>\n#include <string.h>\n\nint main() {\nunsigned char mem[30000];\nunsigned char *ptr = mem;\nmemset(mem, 0, sizeof(mem));\n\n/* BF code */\n%s\nreturn 0;\n}\n' % __import__('re').sub(r'[^\+\-\[\],\.><]', '', __import__('sys').stdin.read()).replace('+', '++*ptr;').replace('-', '--*ptr;').replace('[', 'while (*ptr) {').replace(']', '}').replace('>', '++ptr;').replace('<', '--ptr;').replace(',', '*ptr = getchar();').replace('.', 'putchar(*ptr);')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment