Back to General discussions forum
Hi,
I am having a problem with "Problem 117 - Divide by Two".
Specifically, I get the error 'Error: Data pointer is decremented below zero with "<" operation'. However, if I try it in my interpreted, this issue does not arise (and indeed provides the correct solution for various numbers - except 1). Can someone help me figure out why the solution interpreter returns that I go below index 0?
Cheers! David
Hey David,
Haven't solved this one myself, but here's my two cents.
Your interpreter probably avoids this by correcting the data pointer for modulo data size after < or >. I know mine does, but the checker might not.
Have you tried just adding a couple > at the beginning of your BF code?
Oh, and stop flying up the ranks dude, I'm having trouble keeping up with you! ;)
Hi Midwinter,
Good suggestion! Unfortunately it does not seem to be the issue. I checked whether my command ever has the command "<" whilst already in cell 0 (for various input digits), and it never seems to be the case. To double check, I also purposefully added another "<" and the interpreter was willing to go into the negative. Finally, I also tried submitting the solution with an additional ">>>" at the start of my code to see if this would maybe be accepted, but I still get the error that my Data Pointer goes below zero...
In any event, thanks for the suggestion. If anyone else has any further thoughts, these are greatly appreciated.
In the meantime I may have to move to other puzzles to stay ahead of Midwinter...! :-)
Hi Friend!
Have you debugged any input value step-by-step? Use pencil and paper if there is doubt about your interpreter...
Your code does bit too strange manipulations with shifts, so it is easy to go wrong. See, here is its beginning if I'm not wrong:
;>>>>>+<<<<<[-->+<[->>+<<[+>>-]>>>>]< ...
Let input be 2, you store it in the data cell 0, after first opening bracket you decrement it to 0 hence you skip the second pair of brackets and come to the last "backshift" in this fragment. As DP at this moment is 0, you obviously get out of data array...
Hope I'm not missing something and this helps!