Advent of Code - Day 3 (Part 2)
I finished the second exercise and I definitely didn’t make my solution any faster like I said I might. I may return to it eventually but for now I’m still playing catch up on the challenges.
In the second part of this day’s puzzle they are switching up the distance calculation. Instead of looking for the intersection with the shortest Manhattan distance, we will now need to find the shortest “signal” distance. Basically, the intersection at which each wire’s path is the shortest.
We can measure this distance using the position
function which returns the (first) index of a specific value in a list. We’ll also re-use our vector-equal
function again for the comparisons:
Then it is just a small change to swap out the Manhattan distance mapping for our own:
My full solution can be found on Github.