Day 18: Ram Run
Todays challenge was another shortest path first exercise, so once again cracked out Dijkstra algorithm from Day 16.
With a few tweaks and adjustments around costings and such as the costings were more straight forward as every movement was the same price.
Part 1
I began by filling in the corrupted locations, which then gives the terrain for finding the best route using Dijkstras algorithm. Returning the lowest amount of steps.
Part 2
Loop over the input and for each additional corruption check if you can reach the exit.
This could be optimised to work in reverse as we know itβs more likely to occur when more corruptions are added than at the beginning (but that would be a big assumption, and may not be the case for all inputs as in Part 1 we only ran the first 1024 bytes out of 3k+.
As always feel free to reach out on Twitter
Top comments (0)