Skip to content

Instantly share code, notes, and snippets.

@lutoma
Created June 7, 2016 15:56
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 lutoma/78132af5741229e6f8efa9734463b0fd to your computer and use it in GitHub Desktop.
Save lutoma/78132af5741229e6f8efa9734463b0fd to your computer and use it in GitHub Desktop.
print('main(){int*i=malloc(9999);',*map(lambda _:dict(zip('><+-.,]',[y+';'for(y)in'++i|--i|++*i|--*i|putchar(*i)|read(0,i,1)|}'.split('|')]),**{'[':'for(;*i;){'}).get(_,''),__import__('sys').stdin.read()),'}')
@lutoma
Copy link
Author

lutoma commented Jun 7, 2016

Pro tip™: Try

echo ">++++++++[-<+++++++++>]<.>>+>-[+]++>++>+++[>[->+++<<+++>]<<]>-----.>->+++..+++.>-.<<+[>[+>+]>>]<--------------.>>.+++.------.--------.>+.>+." > brainfuck
python -c "print('main(){int*i=malloc(9999);',*map(lambda _:dict(zip('><+-.,]',[y+';'for(y)in'++i|--i|++*i|--*i|putchar(*i)|read(0,i,1)|}'.split('|')]),**{'[':'for(;*i;){'}).get(_,''),__import__('sys').stdin.read()),'}')" < brainfuck | gcc -o hello -xc -
./hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment