Skip to content

Instantly share code, notes, and snippets.

@dpk
Last active February 18, 2022 15:20
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 dpk/5499005 to your computer and use it in GitHub Desktop.
Save dpk/5499005 to your computer and use it in GitHub Desktop.
Brainfuck compiler in 182 bytes. (172 without shebang; 163 without shebang or automatic feeding to C compiler)
#!/bin/sh
tr -Cd '][.,<>+-'|sed 's/\./putchar(*p);/g;s/,/*p=getchar();/g;s/[+-]/&&*p;/g;s/[<>]/&&p;/g;s/\[/while(*p){/g;y/]<>/}-+/;s/^/main(){int a[30000];int *p=a;/;s/$/}/'|cc -xc -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment