Created
April 15, 2014 02:20
-
-
Save EvanHahn/10696763 to your computer and use it in GitHub Desktop.
Daily programmer #158, in Brainfuck
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
first digit | |
,------------------------------------------------ | |
[>++++++++++<-] | |
second digit | |
,------------------------------------------------ | |
>> | |
third digit | |
,------------------------------------------------ | |
[>++++++++++<-] | |
fourth digit | |
,------------------------------------------------ | |
make the first number | |
<< | |
[>+<-] | |
make the second number | |
>> | |
[>+<-] | |
add the two numbers into cell 0 | |
< | |
[<+>>+<-] | |
>> | |
[<<<+>+>>-] | |
make four copies of cell 0 | |
<<< | |
[>>>+>+>+>+<<<<<<-] | |
square this number | |
>>>>>- | |
[ | |
<[<+>-] | |
>- | |
>[<<+>>>+<-] | |
>[<+>-] | |
<< | |
] | |
make the expected number | |
<<< | |
[-<< | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
>>] | |
<[-<+>] | |
subtract the actual from the expected | |
<[->>>-<<<] | |
is the expected nonzero? | |
>>> | |
[ | |
print "n" | |
<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
. | |
print "o" | |
+ | |
. | |
make this print cell negative 1 | |
[-]- | |
make it 0 | |
>[-] | |
] | |
it was zero! | |
<+[ | |
print "yes" | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. | |
--------------------. | |
++++++++++++++. | |
[-] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment