Skip to main content

Module day21

Module day21 

Source
Expand description

§Springdroid Adventure

Jumps are always 4 tiles wide, landing on D. If needed we can jump again immediately landing on H. The intcode program runs faster if the springscript is shorter, so although multiple scripts work, any solution that treats intcode as a black box will be better if the script is minimized.

§Part One

We jump if any of A, B or C are holes and there is ground where we will land at D. This takes 7 instructions:

J = (NOT A OR NOT B OR NOT C) AND D

Using De Morgan’s laws we can simplify to 5 instructions:

J = NOT (A AND B AND C) AND D

But in practice, all input files are set up so that part 1 is just the 7 possible sets of 4 positions with a leading hole but not 4 consecutive holes; this can be solved without ever probing position B, simplifying to 4 instructions:

J = NOT (A AND C) AND D

§Part Two

Now the input files have 153 sets of 9 positions, but again with never more than three consecutive holes. Checking B now matters, and we also need a new rule to jump if H is ground when C is a hole, to trigger a double jump. But overall, this can be done in six instructions. Surprisingly, we never needed to use register T.

Constants§

RUN 🔒
WALK 🔒

Functions§

parse
part1
part2
survey 🔒