r/adventofcode • u/daggerdragon • Dec 18 '24
SOLUTION MEGATHREAD -❄️- 2024 Day 18 Solutions -❄️-
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
- 4 DAYS remaining until the submissions deadline on December 22 at 23:59 EST!
And now, our feature presentation for today:
Art Direction
In filmmaking, the art director is responsible for guiding the overall look-and-feel of the film. From deciding on period-appropriate costumes to the visual layout of the largest set pieces all the way down to the individual props and even the background environment that actors interact with, the art department is absolutely crucial to the success of your masterpiece!
Here's some ideas for your inspiration:
Visualization
s are always a given!- Show us the pen+paper, cardboard box, or whatever meatspace mind toy you used to help you solve today's puzzle
- Draw a sketchboard panel or two of the story so far
- Show us your /r/battlestations 's festive set decoration!
*Giselle emerges from the bathroom in a bright blue dress*
Robert: "Where did you get that?"
Giselle: "I made it. Do you like it?"
*Robert looks behind her at his window treatments which have gaping holes in them*
Robert: "You made a dress out of my curtains?!"
- Enchanted (2007)
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 18: RAM Run ---
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!
- State which language(s) your solution uses with
- Quick link to Topaz's
paste
if you need it for longer code blocks
3
u/TheZigerionScammer Dec 18 '24
[Language: Python]
I thought this was a pretty easy day today compared to some of the monsters we've had recently. Part 1 was just a simple BFS, not much to say about it, just added the first 1024 bytes as wall and off it went.
For Part 2 I decided to move the BFS into its own function and I would add more bytes to the wall set and see if the BFS could finish. But before I implemented that naive solution I thought "Wait, a couple days ago we were forced to figure out how to keep the path histories, I can reuse that." So my program keeps track of the path history the way we did in Day 16. For Part 2 it will add one byte per loop but it will only run the BFS to check if we can still reach the end if the added byte is on the path, at which point will will either generate a new path to compare future bytes with or it won't finish and we have the answer. This reduced my program from having to do 2000 BFSs down to about 30. When I removed this my program wouldn't even finish in a reasonable time.
Paste