I'm currently learning brainfuck as a challenge for golfing, and I'd like a code review to make sure I'm understanding things properly. For starters, here's my snippet:
[
The purpose of this program is to add two
predetermined values together and print the result.
For this program the values 15 and 20 have been
chosen to add together which should give a
result of 35 and print # at the end.
]
+++++ Iterate 5 times
[
>+++ Add 3 to cell one
>++++ Add 4 to cell two
<<- Subtract 1 from cell zero
]
Currently cell one is 15 and cell two is 20
The resulting output should be 35
>[ Move to cell one and iterate until cell one is zero
>+ Add 1 to cell two
<- Subtract 1 from cell one
]
>. Print cell two
The objective of this snippet is to take two predetermined values 15
and 20
, add them together (resulting in 35
), and print the result to the console. Since brainfuck works with ASCII values, the octothorp should be printed to the console at the end:
#
I'm sure there are shorter ways to do this, but I'm looking for feedback on how well I've documented what it's doing, the formatting/style of the breakdown, and the overall approach to the problem.