Advent of Code 2019

The story of my slow descent into madness

View on GitHub
21 December 2019

Day 21: Springdroid Adventure

by Simon Berger


Links:

We’ve come full circle! We’re writing code for an interpreter written in intcode which is then run by our intcode interpreter. I’m trying really hard to avoid making an Inception reference, but oh well. The task itself was pretty easy so I suspect we’ll see this again in a more complex form.

For the first part we can just jump whenever we know we can land safely. The springbot always jumps 4 units (i.e. it lands on D) so we should only jump if there is ground at D.

  __
 /  |
|   v
#...#
 ABCD

We only need to jump if there’s a hole to jump over though (i.e. there is no ground at either a, b, or c). Using logic notation that would be or simply .

The second part doubles the view distance from four units to 8. At first it might seem like that doesn’t change anything and the same logic still applies, but it doesn’t. We need to keep in mind that it’s possible to construct impossible jumps for the first part. For example ###.#.##. will result in the robot jumping into the void.

  __  __
 /  |/  |
|   ⇵   v
###.#.##.
 ABCD
     EFGH

The robot can’t predict that it needs to delay its jump until it reaches B so that it could land on F simply because it doesn’t see that far. The first part obviously doesn’t have any such jumps as that would make it impossible to solve.

Because of the increased view distance we can now account for this situation. To avoid ending up in this situation we need to ensure that there’s ground at either H or E. If neither of them has ground then we’re dealing with the situation from above so we simply don’t jump. The logic for this is . As you can see it’s just the previous condition extended with the check.

Today’s puzzle didn’t really involve any programming. I mean it did, technically, but not in the way we’re used to. It’s an interesting concept though and I do hope that it will be expanded in one of the last two intcode puzzles.

tags: intcode - springcode
Overview
Previous day Next day