r/code • • Apr 27 '22

Help please! brainfuck code

+>+[[>+>+<<-]<[>>>+<<<-]>>>.]

A friend and I like to sebd each other encrypted messages as puzzles. I think this is brainfuck code, but I can't figure out the output.

9 Upvotes

3 comments sorted by

9

u/iamawhale1001 Apr 27 '22

I ran through it on paper , and it appears to output the fibonachi sequence, 2, 3, 5, 8, 13, etc.

It's pretty straitforward to learn how to read it. All you need to know is there's a "tape" that stores numbers, and a pointer that points to a position on the tape.

 + increments the number the pointer is at
 - decrements the number the pointer is at
 > moves the pointer right one space 
 < moves the pointer left one space 
 [] are sortof like a loop operator. Think of it like while (number_at_pointer != 0) /{ do whats between the brackets }
And lastly, the . Operator prints the number at the pointer to the "screen" or output buffer. 

Theoretically you can do anything any computer can do with these 6 operators , the output operator is just for convenience, but it technically isn't even needed for the language to be turing complete.

Edit: formatting

4

u/subslash Apr 27 '22

Damn that must be it. I converted the output straight to Ascii without really looking at it and started messibg aroubd with character frequencies. Thanks for the reply!

3

u/justingolden21 Apr 28 '22

I think comma takes input also, but wouldn't matter for this case.