Brainfuck program to generate next binary number
- initial mark (FF) | |
read input 49 = 1 and 48 = 0 (q0) | |
>>,[>,<-------- -------- -------- -------- -------- -------- >] | |
- final mark (FF) | |
<[-<] change ones for zeros until a zero is found (q1) | |
+ change zero for one (q1 to q2) | |
< ignore all characters until FF is found (q2) | |
+ increase by one (ensures that the data pointer moves until FF is found) | |
[ if the byte at the data pointer is zero then FF was found | |
- it wasn't zero decrease it | |
< move left to check next bit | |
+ increase by one as before | |
] begin printing | |
>-[>-]+ ensure that no leading 0s are printed | |
+ increase by one to ensure that the byte at the data pointer is not FF | |
[ | |
add 47 (to print the character as either 0 or 1) | |
++++++++ ++++++++ ++++++++ ++++++++ ++++++++ +++++++ | |
. print character | |
> go to next character | |
+ add 1 as before | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment