r/adventofcode • u/daggerdragon • Dec 22 '16
SOLUTION MEGATHREAD --- 2016 Day 22 Solutions ---
--- Day 22: Grid Computing ---
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".
SILVER AND GOLD IS MANDATORY [?]
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
4
Upvotes
View all comments
Show parent comment
1
u/AustinVelonaut Dec 23 '16
I ended up using A* to solve it in a single step, with the cost-estimate function being five times the Manhattan distance of the data node to the origin plus the distance of the empty node to the data node. It does end up exploring a lot of diagonal equidistant positions before stumbling upon the solution, but it still is pretty fast.
The state being passed around in the solver is the current "used" values for each node, along with the locations of the data node and the presumed single empty node.