What's wrong with my new Brainfuck add-on program?

I've been working on this programming challenge: http://www.codeabbey.com/index/task_view/summing-up

It basically says:

Input data has two values A and B in the single line.
Output should have the sum A+B printed into it.
Additionally after the stop the program should have values A, B, A+B in the cells 0, 1 and 2 respectively.

      

So, for example, the input would look like this:

9 26

      

Now I think I don't understand the problem or solution because I believe the solution should be 9 26 35

where 9, 26 and 35 are in their own cells.

My solution returns 9 26 35

and I believe in the correct cells (0,1 and 2), but I am wrong. Can anyone look at the problem and my code and tell me where I am going wrong?

code:

;:>;:><[-<+>]<:

      

+3


source to share


2 answers


I tried connecting this to the online translators password with brain stubbornness. There is one of them here:

http://copy.sh/brainfuck/

and more here:

http://esoteric.sange.fi/brainfuck/impl/interp/i.html

In both cases, I need to slightly change my character set ->: becomes. and; becomes,



The output from both parameters was

    9 Y

      

Note that 35 - 9 = 24, and Y is the 24th letter of the alphabet. I think you are printing the number "35" and interpreting it as a letter.

I would try changing the program so that your output is literally single digits of the answer, i.e. outputted 3 and then outputted 5 instead of outputting the numeric "35" (but leaving the numeric value in cell 2 at the end). In other words, your text output should be a formatted version of the values ​​in memory, not just output numeric values ​​directly.

+1


source


It looks like the output should only have A+B

, not A

, B

and A+B

as you do with :

.

And your result looks like it will have A+B

0s in cell and 0s in cell 1 (essentially the same as in the example code).



><

simply cancels itself.

+1


source







All Articles