r/adventofcode • u/daggerdragon • Dec 03 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 3 Solutions -🎄-
--- Day 3: No Matter How You Slice It ---
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!
ATTENTION: minor change request from the mods!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 3 image coming soon - imgur is being a dick, so I've contacted their support.
Transcript:
I'm ready for today's puzzle because I have the Savvy Programmer's Guide to ___.
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!
42
Upvotes
View all comments
Show parent comment
3
u/AustinVelonaut Dec 03 '18
It worked fine, for me. Each claim (rectangle) is entered whole if it doesn't overlap any existing rectangles. Otherwise the claim and the first overlapping tile are broken up into a set of smaller rectangles (claim-only, up to 4), intersection, (tile-only, up to 4). The new tiles are added to the tile set (known to be disjoint), the new claims are added to the claim set to be processed, and the overlapping tile is replaced by the single overlap intersection.
The solution saves on space compared to the "Really Big Array", and saves on space and time compared to the "break everything up into sets of 1x1 cells" solution.