I have an off by one in my data, but the example i...
# advent-of-code
g
I have an off by one in my data, but the example is fine. Earlier I had 43 in the example, since I didn't use the different geologic index to calculate the points 'behind' it.
k
Where is the off-by-one? Part 1 or part 2?
g
Only part 2, only in the real data. When I filter options more aggressively it does give the 'right' answer.
k
What options? What filtering?
g
How I handled the problem was kind of brute force, going to any direction, when needed changing tools. to prune it back I check the location and how fast that location has already been reached. When the current time is 7 or more slower the option can be removed (since whatever equipment is used, it could be changed and have the same time). If I set the time to check to the current fastest minus 3 I get the 'right' answer.
k
Do you also handle cases where multiple points downwards can be reached faster by changing tools?
g
I handle any case, once I have a time of a path reaching the target, I start trimming any path taking longer.
k
Not sure whether that approach works in general, it's not one of the standard pathfinding algorithms. I'd just add "tool" as a 3rd axis and pathfind on that.
g
But how did you account for the 3rd axis being more expensive?
k
Keep a priority queue with states
(x,y,tool,time)
that are sorted by the
time
it took to reach them.
(while running something like Dijkstra or even A*)
g
Thanks, solution for part 2 runs correctly now, and under a second.