Summing Up Problem 116 - DescriptionInstructions are not clear

Back to General discussions forum

ssvipl64     2021-07-14 10:47:50

Summing Up Problem #116

Need help in understanding the problem statement

I think , the description about the problem is not sufficient on what is expected to be performed.

When I am trying to print the sum of the two numbers -- The error comes like this.

Error: Limit of operations (100000) reached before program finished!

Is this a problem meant to be solved only with BrainFuck !!!.

qwerty     2021-07-14 13:48:19

Yeah mate, this problem is intended to be solved only on Brainfuck (with Python it would be too easy, don't you think?).

See, your code have the following line:

arr.append(arr[0]+arr[1])

Brainfuck interprets this line as follows:

  1. Command + orders interpreter to increment value in current memory cell - after this value of current memory cell becomes equal to 1.
  2. Characters 'a', 'r', 'r' ignored.
  3. Command [ signals the start of loop.
  4. Character '1' ignored.
  5. Command ] check the loop end condition. Because the value of current cell is 1 and is not equal to 0, program returns to previous command [ and loop continues.
  6. Command ] reached again, loop continues...
  7. And so on, until limit of operations exceeded - thanks god such limit exists.

Please refer to article Brainfuck Wiki for details.

qwerty     2021-07-14 14:11:05

Additionally, I took a look at problem statement / instructions and I think they are pretty clear.

You are asked to modify a Brainfuck program - obviously result should be Brainfuck program too!

Please login and solve 5 problems to be able to post at forum