Skip to content

Instantly share code, notes, and snippets.

@lutoma

lutoma/brainfuck.py

Created Jun 7, 2016
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@lutoma 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