28
2
Your task is to write a piece of code that zeros the current cell in the Brainfuck variant that, each cell can contain a signed integer of arbitrarily large magnitude, instead of the normal 0 to 255.
You may assume there are l cells to the left and r cells to the right of the current cell that are initially zero. You program may only access these l+r+1 cells. After your code ends it should leave the l+r extra cells zero and the pointer to the current cell at the original position.
You may not use any input/output.
The code with smallest l+r wins. If there is a tie, the shortest code wins. It is recommended to also state the time complexity of your program for reference, where n is the absolute value of the original integer in the current cell.
Useful tools
You can test a Brainfuck program in this variation using this interpreter on TIO by mbomb007.
You can also use the interpreter in this answer by boothby (other Python answers probably also work, but I didn't test).
I have tagged it code-golf because I think we will reach the optimal l+r quickly. – jimmy23013 – 2017-05-02T15:23:26.207
2It sounds like from your comment, you meant arbitrarily large magnitude integer, which may be positive or negative. This is a difference in english dialect for some people, so it might be helpful to clarify that it can be very positive or very negative. – isaacg – 2017-05-02T15:29:41.730
4@jimmy23013 Do you have a BF interpreter with signed cells we can use for this? – mbomb007 – 2017-05-02T15:35:37.903
@mbomb007 https://codegolf.stackexchange.com/a/3085/25180 but probably too golfy...
– jimmy23013 – 2017-05-02T15:54:02.477This is a code challenge, not code golf. The length of the code does not play any part in the scoring. – Mego – 2017-05-02T15:58:05.823
@Mego It is the tiebreaker. I don't think it is that challenging to reduce l+r. So after we got the optimal l+r it would be the real challenge, which is code-golf. – jimmy23013 – 2017-05-02T16:00:54.493
Then this is a chameleon challenge, where the l+r is a distraction from the "real" challenge of golfing the code. Regardless, the primary winning condition is not shortest code, so this isn't code golf, regardless of the fact that the secondary winning condition is shortest code and will probably play more of a part in deciding the winner. – Mego – 2017-05-02T16:01:37.833
1@Mego Why? In the "real" challenge, you must also get the optimal l+r, which will probably make it more difficult to reduce the code size. – jimmy23013 – 2017-05-02T16:05:12.203
@Mego I had no idea what is the best tag. So I'll leave it code-challenge as you edited until someone disagrees. – jimmy23013 – 2017-05-02T16:06:08.780
@mbomb007 The default tiebreaker is first answer to reach the tied score. – Mego – 2017-05-02T16:14:00.760