Advent of Code - 2019 - Day 9-10

The ninth problem was yet another twist to the Intcode machine. This time relative addressing was introduced, and I decided (since we didn’t need more than one process) to build it on top of the solution from Day 5. Implementation was entirely straightforward. Two complications that were mentioned in the problem descriptions, large numbers and memory addressing, was entirely trivial since we have large numbers built-in and were using a map for memory.

Part 2 took a long time to run, around 2 minutes, but with inlining and some other tweaks (not part of the presented solution) it could be brought down to about one minute…

My solution is here

The [tenth problem]((Day 10 - Advent of Code 2019) was about line of
sight in an asteroid field. In part 1 we were tasked to find the asteroid that
had most asteroids in line of sight. Again we were handicapped by not having
any string processing functions so I transformed the input into a list of list
of 0’s and 1’s.

The algorithm is nothing fancy, for each asteroid find the line of sight vector
to each other asteroid (normalized) and then count the number of unique
vectors. The problem had ~400 asteroids and this ran to completion in about 15
seconds. In part 2 we were using a laser to blast the asteroids (laser rotating
clockwise) and the task was to find which asteroid would be the 200th to be
evaporated. The implementation actually computes the entire list in which order
the asteroids are targeted, but since 200 is less than the answer to part 1 we
could have gotten away with a less complex solution. This is quick to compute,
less than half a second.

My solution is here