Human Resource Machine/Year 9

Strategy
This is simply the inverse problem of. Instead of ignoring the zeros and moving everything else, you will do the opposite. Move the zeros and ignore everything else.

To do this, start with the program from Year 7 (you can copy it from that year, and paste it in this year.) Only now you will add another jump instruction. If the value is zero, instead of jumping to the start of the program, you will jump down to the OUTBOX instruction. However, if it's not zero, you must then jump back to the top of the program.

a: b:   INBOX JUMPZ   c    JUMP     b c:    OUTBOX JUMP    a

Optimizing
Aside from, this is the first time that your program may be short enough, but not quick enough. Contributing to the problem is that fact that when you decide to go to the OUTBOX, you have to jump to it, and then jump back to the start of the program. This is inefficient. It would be better if you didn't have to waste an instruction between the OUTBOX and the INBOX.

You can accomplish this by placing the OUTBOX instruction before the INBOX instruction. However, the very first time you run this program, you can't go to the OUTBOX empty handed. So only for the very first time, you'll jump over that instruction and go straight to the INBOX instruction. From there, the program will run with one less instruction between the OUTBOX command and the INBOX command.

JUMP    b a:    OUTBOX b: c:   INBOX JUMPZ   a    JUMP     c