Last active
July 3, 2018 13:52
-
-
Save TheLie0/a9f39c74d937c4ce8ecc8bca41ab8b60 to your computer and use it in GitHub Desktop.
Brainfuck program that returns the ascii values of the input characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>>, | |
[<<+>>>>>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++<<<<< initialize memory | |
> read input | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++< set up memory for 100s | |
[+>+<[->-[>]<<]<[ if a is greater or equal to b then | |
- >>>>>+ add one at 100s place | |
<<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<< put b back to 100 | |
]<[ else | |
- >> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > [-<->] <<<+<reset a to value before checking | |
] +>> put back one so another loop can happen | |
]checks for 100s | |
<<->> reset number to the left to avoid later errors | |
>>++++++++++< set up memory for 10s | |
[+>+<[->-[>]<<]<[ if a is greater or equal to b then | |
- >>>>>>+ add one at 10s place | |
<<<++++++++++<< put b back to 10 | |
]<[ else | |
- >> ++++++++++ > [-<->] <<<+<reset a to value before checking | |
] +>> put back one so another loop can happen | |
]checks for 10s | |
<<->> reset number to the left to avoid later errors | |
>>+< set up memory for 10s | |
[+>+<[->-[>]<<]<[ if a is greater or equal to b then | |
- >>>>>>>+ add one at 1s place | |
<<<<+<< put b back to 1 | |
]<[ else | |
- >> + > [-<->] <<<+<reset a to value before checking | |
] +>> put back one so another loop can happen | |
]checks for 1s | |
<<->>>->> cleaning up the now usuless numbers | |
.[-]>.[-]>.[-] printing the answer | |
<<<<< go back to a spot for eventual new letters | |
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ out the value of ; into memory for splitting numbers | |
.----------------------------------------------------------- print and remove value | |
,]read next letter and check if there is one | |
<<< go back to memory location 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If/else code used from: https://gist.github.com/YetAnotherMinion/a1978c7e709e08ad3012