Human Resource Machine/Year 37

Strategy
The concept that this level introduces is known as a linked list. A linked list contains two pieces of information. One is a piece of data that the list stores, and the second is where to find the next piece of data.

The instructions pretty much spell out the strategy for you. In this challenge, you will grab a number off the INBOX. Then copy it somewhere so you can reference it. Once copied, you will go to the address is specifies and copy the letter to the OUTBOX. Then bump the index up by one to get the next value in the pair which will be another address. As long as that value is not negative, go ahead and copy it over the initial address and continue until you reach a negative number. Then grab another number from the inbox and continue with that chain until there are no more numbers in the INBOX.

This very short program will look like so. Note that we are saving an instruction by looping back to the COPYTO 7 instruction instead of using two separate such instructions, one after the INBOX and one between the two jump commands at the bottom.

a:   INBOX b:   COPYTO   7 COPYFROM [7] OUTBOX BUMPUP  7 COPYFROM [7] JUMPN   a    JUMP     b

Optimizing
It's technically not possible to further optimize the above program. However, it is possible to exploit the fact that the game really only ever generates the phrases "APEESCAPE" or "ESCAPEAPE" and tailor a program that writes one of those two phrases very quickly.