Skip to content

Instantly share code, notes, and snippets.

@Reinmar
Created September 7, 2011 00:14
Show Gist options
  • Save Reinmar/1199370 to your computer and use it in GitHub Desktop.
Save Reinmar/1199370 to your computer and use it in GitHub Desktop.
Brainfuck
for(b=[],o='',i=c=l=0;u=s[i++];)l<0?u==']'&&l++:(b.push(0),u=='['?(l=b[c]?i-1:-1):u==']'?i=l:u=='.'?o+=b[c]:u=='+'?++b[c]:u=='-'?--b[c]:u=='>'?++c:u=='<'?--c:o)
@neizod
Copy link

neizod commented Oct 5, 2011

wow!

@Reinmar
Copy link
Author

Reinmar commented Oct 5, 2011

hehe ;> i had to think for a while before i recalled what that was :D

@neizod
Copy link

neizod commented Oct 5, 2011

if you can save some more 30 bytes, may be this will be the coolest code on 140byt.es!!

@Reinmar
Copy link
Author

Reinmar commented Oct 5, 2011

30 bytes is impossible - i tried and i'm nearly sure about that. But I wrote version without loops:

for(b=[],o='',i=c=0;u=s[i];)b[i++]=0,u=='.'?o+=b[c]:u=='+'?++b[c]:u=='-'?--b[c]:u=='>'?++c:u=='<'?--c:o

103 chars

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