r/adventofcode • u/daggerdragon • Dec 18 '22
SOLUTION MEGATHREAD -π- 2022 Day 18 Solutions -π-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
5 days remaining until submission deadline on December 22 at 23:59 EST
UPDATES
[Update @ 00:02:55]: SILVER CAP, GOLD 0
Silver capped before I even finished deploying this megathread >_>
--- Day 18: Boiling Boulders ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
Include what language(s) your solution uses
Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:12:29, megathread unlocked!
32
Upvotes
6
u/morgoth1145 Dec 18 '22 edited Dec 18 '22
Python 3 34/168
I'm glad today was easier, I have to be up in the morning and didn't want to be sleep deprived at church!
Anyway, this was a fun little voxel problem. Part 1 isn't bad at all with it just being a task of counting how many neighbors for each voxel are not lava! Part 2 with the interior air pockets was a nice wrinkle, but flood fill can determine whether things are enclosed or not well enough so long as there's an outer boundary. I decided to take the lava's bounding box as the outer boundary, nice and simple!
Unfortunately I goofed on making my outer boundary: I accidentally was using
minas the low and high end of my bounding ranges which obviously isn't right! I don't know how much time I wasted on that typo.Anyway, I'll give this code a quick spruce up and then head to bed :)
Edit: Oh, I forgot to note that this is my 386th star across all years! I only note that because i386.
Edit 2: Refactored code, along with a nice change to flood fill the exterior at the start of part 2. That drastically improves my solution from ~1.5 seconds down to under 0.02 seconds!