Skip to content

Instantly share code, notes, and snippets.

@justinvh
Created January 11, 2014 03:31
Show Gist options
  • Save justinvh/8366633 to your computer and use it in GitHub Desktop.
Save justinvh/8366633 to your computer and use it in GitHub Desktop.
stupidly simple C output bf
import sys
preamble = '#include <stdio.h>\nmain(){char a[5000]={0};char *p=a;%s;return 0;}'
cmds = {'>': '++p;', '<': '--p;', '+': '++*p;', '-': '--*p;',
'.': 'putchar(*p);', ',': '*p=getchar();', '[': 'while(*p){', ']': '}'}
print(preamble%(''.join(cmds.get(i, '') for i in sys.stdin.read())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment