Skip to content

Instantly share code, notes, and snippets.

@jeremy-rifkin
Created February 11, 2021 03:20
Show Gist options
  • Select an option

  • Save jeremy-rifkin/28980cc3507ae691fbf1659654c78500 to your computer and use it in GitHub Desktop.

Select an option

Save jeremy-rifkin/28980cc3507ae691fbf1659654c78500 to your computer and use it in GitHub Desktop.
Code golfed brainf interpreter
// brainf interpreter code golf
// collaboration by some folks on discord and myself
#include <stdio.h>
#define r(c) ;i++;goto w;case c:
i;t[99];s;p=1024;char b[2048];main(int j,char**a) {
fread(b,1,p,fopen(a[1],"r"));
w: switch(b[i]) {
r(45) b[p]--
r(43) b[p]++
r(60) p--
r(62) p++
r(46) putchar(b[p])
r(44) b[p]=getchar()
r(91) if(b[p])t[s++]=i;
else for(j=0; b[i]-93||j-1; i++)b[i]-91?b[i]-93?0:j--:j++
r(93) i=t[--s]-1
r(0) break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment