Skip to content

Instantly share code, notes, and snippets.

@DarkSeraphim
Last active January 30, 2019 15:05
Show Gist options
  • Save DarkSeraphim/97161744742cf929b58f250f61b0cfb8 to your computer and use it in GitHub Desktop.
Save DarkSeraphim/97161744742cf929b58f250f61b0cfb8 to your computer and use it in GitHub Desktop.
Move right and request number
>
Get char
,---- ---- --
[
++++++++++
>[-]>[-]>[-]<<< Reset next two slots
> ++ ++++ ++++ <
<[->>>+<<<] Copy number to next two slots
>>
[
- Decrement for mult
>[-<<<+>>>>+<]
>[-<+>]
<<
]<
Parse number (subtract '0')
>[-]
>[-]++++ ++++ ++++ ++++
[-<+++[-<->]>]
<<
[-<+>]
,---- ---- --
]<
> move to A and keep 0
>+ move to B and set to 1
<< move back to N
[
move to B
>>
copy B to C and D
[->+>+<<]
Move to A
<
Add A to C (now C is A plus B)
[->>+<<]
Move to D
>>>
Add D to A (A = B)
[-<<<+>>>]
<[-<+>]
<<<
-
]
>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment