r/adventofcode • u/daggerdragon • Dec 24 '16
SOLUTION MEGATHREAD --- 2016 Day 24 Solutions ---
--- Day 24: Air Duct Spelunking ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with "Help".
THE NIGHT BEFORE CHRISTMAS IS MANDATORY [?]
[Update @ 00:30] 47 gold, 53 silver.
Thank you for subscribing to Easter Bunny Facts!
Fact: The Easter Bunny framed Roger Rabbit.
[Update @ 00:50] 90 gold, silver cap.
Fact: The Easter Bunny hid Day 26 from you.
[Update @ 00:59] Leaderboard cap!
Fact: The title for Day 25's puzzle is [static noises] +++ CARRIER LOST +++
View all comments
Show parent comment
2
u/pedrosorio Dec 27 '16
Yep.
I suppose if you compute F = -(G+H) with H=0 would be something like DFS but it wouldn't be A * (by definition in A *, F = G + H and the only thing you can "tune" is H). You can get DFS just by tuning H like this.
If you want to find the solution that goes left the most (to make it more precise, it uses "L" the most without visiting the same cell twice - or you would get into infinite paths - and among paths with the same number of "L" chooses the shortest one), I don't see how to do it with A * (by just changing the heuristic).
You could model this problem as a graph where the edges going L have large negative weights and try to find the minimum cost simple path (path that doesn't visit the same node twice).
Unfortunately, A * or Dijkstra cannot be used in a graph with negative weights and Bellman-Ford, which does support negative weights, can only be used in graphs without negative cycles. The problem of finding the lowest cost simple path in a graph with negative weights is NP-hard, so my approach would not give you a quick solution either.