Instructions[edit]
Strategy[edit]
You've had an ADD instruction, so now you get a SUB instruction.
- SUB
- This instruction is always accompanied by a number. The instruction tells the worker to walk over to the box on the floor labeled with the specified number. The worker will then subtract the value in the box from the value in his/her hands. The difference will appear in his/her hands. Note that you cannot instruct the worker to SUB if he/she is not holding anything.
The important thing to note here is what gets subtracted from what. You are always subtracting the value in the box from the one in your hand, not the other way around.
In order to accomplish this task, you are required to preserve the values from the inbox so that you can perform the subtraction operation twice. Otherwise, you risk losing one of the values the first time, and you will be unable to perform the second subtraction. So start by copying the values to two different boxes.
When that is finished, you will still be holding the second value in your hands. You can then subtract the value in the first box from the value in your hands for the first difference. After dropping it off, you can then copy the first value and subtract the second value from the first for the second difference and drop that off.
a: INBOX COPYTO 0 INBOX COPYTO 1 SUB 0 OUTBOX COPYFROM 0 SUB 1 OUTBOX JUMP a
Optimizing[edit]
It is not possible to further optimize this solution.
However, while it is true that for ANY input sequence it can not be further optimized, in the game the 5th and 6th number are always the same. Therefore, it can be achieved in 35 moves:
INBOX COPYTO 0 SUB 0 COPYTO 2 INBOX SUB 0 COPYTO 0 OUTBOX COPYFROM 2 SUB 0 OUTBOX INBOX COPYTO 0 INBOX SUB 0 COPYTO 0 OUTBOX COPYFROM 2 SUB 0 OUTBOX INBOX INBOX COPYFROM 2 OUTBOX COPYFROM 2 OUTBOX INBOX COPYTO 0 INBOX SUB 0 COPYTO 0 OUTBOX COPYFROM 2 SUB 0 OUTBOX
Performance[edit]
Steps Size Speed Goal 10 40 Reached 10 40