Skip to content

Instantly share code, notes, and snippets.

@lsmoura
Created April 11, 2018 14:51
Show Gist options
  • Save lsmoura/36d3a3f0e55305210b46aa8fa25aa81f to your computer and use it in GitHub Desktop.
Save lsmoura/36d3a3f0e55305210b46aa8fa25aa81f to your computer and use it in GitHub Desktop.
Brainfuck snippets
[
Simple adder. Adds all available inputs and outputs the sum
Use it on https://codepen.io/lsmoura/full/ZxPqyE/
Make sure to set the result type to 'number'
]
> Leave current memory position blank
>,[>,] Read all the inputs until zero
<< Go to the memory space to accumulate the number from the next space
[>[-<+>]<<] Accumulate until we reach the First value (which is zero)
>[-<+>]< Add the value from the following position to the current position
. Print our result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment