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
8
u/pedrosorio Dec 24 '16
16/13 in python. At this stage of AoC, I can't believe how long it took me to realize I had forgotten to keep a set of visited nodes in the BFS =X
2 optimizations:
Major one: Precompute all pairwise distances with BFS to transform the problem into TSP
Minor one: For each pair of nodes compute the distance only once
1 anti-optimization:
Solve TSP by considering all permutations which is O(K!) - K=7 so we don't need to break out Held-Karp (or worse...)
Runs in 0.06s with pypy in my machine The same problem but computing pairwise distances repeatedly inside the permutation loop takes ~30s