Skip to content

Instantly share code, notes, and snippets.

@lasarus
Created August 4, 2014 19:32
Show Gist options
  • Save lasarus/ec76f0c817e6d888fc63 to your computer and use it in GitHub Desktop.
Save lasarus/ec76f0c817e6d888fc63 to your computer and use it in GitHub Desktop.
Read input until newline and translate into a number
, ----- ----- [ +++++ +++++
> [ - > +++++ +++++ < ]
+++++ +++ [ - < ----- - > ]
< [ - >> + << ]
>> [ - < + > ]
<< , ----- ----- ]
Start loop and run the algorithm on each number between zero and the input number
>> - < [ > +
[ - > + >> + <<< ] > [ - < + > ] >>
Decide the parity of the number
Divide the number by two until it is zero and sum the remainders
[
[ >> + << - < + >> + < [ < - >> - < [ - << + >> ] ] << [ - >> + << ] > [ - > + >> - <<< ] > - ]
>> [ - << + >> ] <<
] >
Run Modulo 2 on the remainder sum and print the result
[ - < + >> + < [ < - >> - < [ - << + >> ] ] << [ - >> + << ] > [ - > + < ] > - ] >
< +++++ +++ [ - > +++++ + < ] > . [-]
End the loop if the input number has reached zero
<<<<<< -]
Print newline
+++++ +++++ .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment