How do you complete the speed challenge for Zero Preservation Initiative
In Human Resource Machine, each stage starting with Year 6 has two bonus objectives.
In Year 9, the Speed Challenge is to get it in 25 steps. However, my solution (the standard programming solution) takes 28 steps.
In this puzzle, you must move all 0 inputs to the Outbox. There are 8 inputs and 4-5 of them are 0.
Here's what I came up with
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
JUMPZ c
JUMP b
c:
OUTBOX
JUMP a
In the above, each 0 takes 4 steps and each non-0 takes 3 steps. On average, it's saying this takes 28 steps.
What is the correct sequence to complete this in 25 or less steps?
Solution 1:
-- HUMAN RESOURCE MACHINE PROGRAM --
JUMP b
a:
OUTBOX
b:
c:
INBOX
JUMPZ a
JUMP c
This is based on DJ Pirtu's solution, but solves it with both the size and speed challenges, without relying on the first input being non-zero.