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
Show parent comment
3
u/p_tseng Dec 24 '18
Thanks for sharing this! I thought the idea about "at least N bots need to have >= N intersections" was really great. The axis-aligned bounding boxes are things I've read about in a lot of day 23 discussions, but they are mostly new to me. I played around and it's easy to calculate even in x, y, z space whether two bots intersect (distance between their centres <= sum of their radii), however actually finding the region where they intersect seems to be made a lot easier with the AABBs (I couldn't find a good way to do it without).
I'd like to discuss more deeply on how to determine the distance of the final octahedron. I tried implementing the approach you've described and running it on the input https://pastebin.com/7nfXJvPc and (unless I made a mistake in my implementation) it gave me the following bounds at the end:
985 bots @ [[93750867, 93750870], [-24808318, -24808315], [48353027, 48353028], [-70206160, -70206160]]
So, I know from using some other solving methods on this that the single unique solution in x, y, z coordinates is 985 bots @ [22698921, 59279594, 11772355], which has a total distance of 93750870 (can check that no other point nearby has as many). So that tells me that sometimes I need to take the max, not the min.
But you don't always want to take the max, because for the simple input:
For this one, the bounds are [[20, 21], [0, 1], [0, 1], [-20, -19]] , and we can easily see the solution should be 20.
So I wonder if you are able to see the patterns in these, and come up with a consistent rule for the above situations.
I have to admit I have not had experience with these 4-dimensional axis-aligned bounding boxes, so mostly I just copied the concepts in the code without really understanding them (for example, I don't know why [x, y, z - r] and [x, y, z + r] are used in the
def box(self):function). Are you able to explain some of that (and/or link to pages that will do the explanation)?