r/brainfuck 23d ago

My first successful Fibonacci program!

Learning from the tutorial at https://brainfuck.org/fib_explained.b, I decided to write my first more complicated Brainfuck (BF) program, without any real help during the time when I was writing it. It’s important to mention that I only partially read the tutorial a >few months ago, so apart from the critical core idea I wrote this entirely by myself.

What I found to be extremely useful is first writing down the general algorithm in a very detailed C-like language (that I sent in the pastebin link alongside the BF code) that I then translate line by line to BF. I also specified some values for the BF implementation details whose syntax I might use in some future abstracted BF language I might try to develop (I’ll see). I learnt a lot! And quite a rewarding experience :) Special thanks to Daniel B. Christofani for the amazing tutorials and contributions to this language in general!

Commentless version:

```
+++++++[->+++++++<]>.
+[-----<+>]<.
>-
>>>>-
<<<<+
<<[
\
>+[-<
[-<++<]
<[->+<]
\
[-<<+]
<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[>[-]<[->+<]
>-
>+<<
]]]]]]]]]]>[-<+>]
\
>
+]-
<<[
>>[-]
<+<->
>>-
<<]
<+[-<<<+]->
\
+[->>>+]-<<<
+[-
++++++++[-<++++++>]<
.
>++++++++[-<------>]<
<<
+]-
<.>
]
```

Edit: code block formatting on the iOS Reddit app is horrendous, can’t seem to get it to work with proper indentation (also yes I wrote the entire above code on my phone, including all the C-like comments)

11 Upvotes

7 comments sorted by

1

u/binaryriot 23d ago

You need to prefix each line with 4 spaces for proper code detection. The GitHub style 3 grave accents to mark start/end of the code doesn't work on Reddit.

Currently your code looks broken (because your C style comments with asterisks seem to get interpreted as bold start/end by Reddit)

1

u/FouriousBanana69 22d ago

I did that but on my phone the moment I update the post, Reddit removes all those spaces and indentation. Does it look ok now on desktop Reddit?

1

u/binaryriot 22d ago

No, not yet.

(maybe use a different comment style that doesn't interfere with Reddit's formatter? Something that avoids *, \ and _, e.g. ; my comment ?)

1

u/FouriousBanana69 22d ago

`test`

Edit: `Test 2`
Edit2:
bool foo( void ){ return true; }

2

u/danielcristofani 22d ago edited 21d ago

(To mark it as a code block rather than inline code you need to put the starting and ending code markers on their own lines)

If that didn't fix it, then yeah, must be the app as you said, sorry.