r/adventofcode • u/daggerdragon • Dec 23 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 23 Solutions -🎄-
--- Day 23: Experimental Emergency Teleportation ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or 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.
Advent of Code: The Party Game!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 23
Transcript:
It's dangerous to go alone! Take this: ___
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
View all comments
1
u/Fyvaproldje Dec 23 '18
I don't see solution similar to mine posted here already, so here it is:
I noticed that every nanobot's region is a cube, but a rotated cube. Also distance from (0,0,0) to every point on a single facet of a single cube is the same. So I switched the coordinate system to one where the cubes are parallel to the axis. Then run something like sweep plane through the space, and on every facet of a cube (only 2 of them are interesting) run a sweep line through the 2D cross-section of the space.
There are some obvious optimizations which can be done (e.g. deduplication of certain conditions, and preserving state between lines and planes), which I didn't do. The runtime without those optimizations is 75 seconds on my machine, which is not great, but... acceptable. Also it doesn't handle correctly a case if the result is the point (0,0,0).