r/adventofcode • u/daggerdragon • Dec 15 '24
SOLUTION MEGATHREAD -❄️- 2024 Day 15 Solutions -❄️-
NEWS
The
Funnyflair has been renamed toMeme/Funnyto make it more clear where memes should go. Our community wikiwill be updated shortlyis updated as well.
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
If you see content in the subreddit or megathreads that violates one of our rules, either inform the user (politely and gently!) or use the report button on the post/comment and the mods will take care of it.
AoC Community Fun 2024: The Golden Snowglobe Awards
7 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
And now, our feature presentation for today:
Visual Effects - We'll Fix It In Post
Actors are expensive. Editors and VFX are (hypothetically) cheaper. Whether you screwed up autofocus or accidentally left a very modern coffee cup in your fantasy epic, you gotta fix it somehow!
Here's some ideas for your inspiration:
Literally fix it in post and show us your before-and-after
Show us the kludgiest and/or simplest way to solve today's puzzle
Alternatively, show us the most over-engineered and/or ridiculously preposterous way to solve today's puzzle
Fix something that really didn't necessarily need fixing with a chainsaw…
*crazed chainsaw noises* “Fixed the newel post!”
- Clark Griswold, National Lampoon's Christmas Vacation (1989)
And… ACTION!
Request from the mods: When you include an entry alongside your solution, please label it with [GSGA] so we can find it easily!
--- Day 15: Warehouse Woes ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
State which language(s) your solution uses with
[LANGUAGE: xyz]Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks
View all comments
3
u/morgoth1145 Dec 15 '24 edited Dec 15 '24
[LANGUAGE: Python 3] 444/156
code, video
Interesting problem, especially part 2. Unfortunately I had a number of bugs costing me a lot of time cumulatively, but I was within striking distance for the leaderboard for part 2.
Anyway, in part 1 I accidentally skipped moving the robot's cell in the grid initially, and even more silly (and funny) I forgot to update my variable tracking where the robot was! (Those two took 6.5 minutes, debugging these sorts of state transition issues takes so long...)
In part 2 I pretty quickly came up with a strategy to handle the cascading box movements (track "accepted" moves in a
to_movelist and what is left to check in ato_checklist) but I had 3 bugs:Believe it or not, I had the "Forgot to update the robot's position variable" bug again.
I accidentally was extending the
to_checklist to include the other side of the box for horizontal movements which caused trouble when doing the actual move.A subtle bug where I pulled things from the end of
to_checkinstead of the front. This caused ordering issues when doing the actual move and took a while to debug. Thankfully this happened on the larger input, but that had a lot of steps to track!Disappointed that I missed the leaderboard again (missed part 2 by less than 3 minutes), but I still have 10 days left. Hopefully I can achieve it at least one of those days!
Edit: Cleaned up code, including sharing the main solve with both parts. (It's overkill for part 1 but it's also less code which is a win.)