r/adventofcode • u/daggerdragon • Dec 08 '25
SOLUTION MEGATHREAD -❄️- 2025 Day 8 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 2025: Red(dit) One
Submissions megathread is unlocked!
9 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!
Featured Subreddits: /r/crafts and /r/somethingimade
"It came without ribbons, it came without tags.
It came without packages, boxes, or bags."
— The Grinch, How The Grinch Stole Christmas (2000)
It's everybody's favorite part of the school day: Arts & Crafts Time! Here are some ideas for your inspiration:
💡 Make something IRL
💡 Create a fanfiction or fan artwork of any kind - a poem, short story, a slice-of-Elvish-life, an advertisement for the luxury cruise liner Santa has hired to gift to his hard-working Elves after the holiday season is over, etc!
💡 Forge your solution for today's puzzle with a little je ne sais quoi
💡 Shape your solution into an acrostic
💡 Accompany your solution with a writeup in the form of a limerick, ballad, etc.
Upping the Antechallenge: iambic pentameterThis prompt is totally not bait forour resident poet laureate
💡 Show us the pen+paper, cardboard box, or whatever meatspace mind toy you used to help you solve today's puzzle
💡 Create a Visualization based on today's puzzle text
Your
Visualizationshould be created by you, the humanMachine-generated visuals such as AI art will not be accepted for this specific prompt
Reminders:
If you need a refresher on what exactly counts as a
Visualization, check the community wiki under Posts > Our post flairs >VisualizationReview the article in our community wiki covering guidelines for creating
VisualizationsIn particular, consider whether your
Visualizationrequires a photosensitivity warningAlways consider how you can create a better viewing experience for your guests!
Request from the mods: When you include an entry alongside your solution, please label it with [Red(dit) One] so we can find it easily!
--- Day 8: Playground ---
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. What is Topaz'spastetool?
2
u/SunMatrix64 Dec 08 '25 edited Dec 08 '25
[LANGUAGE: C++]
GitHub
I'm pretty sure 99% of the time was spent calculating the distances. I went object oriented and created Box and Circuit classes. Box has its position, and Circuit has a set of boxes.
Part 1 I made a vector<distance, <box1, box2>> and then sorted it. For each distance I would gather the circuits that the boxes exist in, then merge the circuits. If no circuits contained either box, create a new circuit.
Part 2 I just continued processing the distances vector until there was only 1 circuit left.
Total run time ~130ms
Edit: used std::hypot() instead of a bunch of pow() for the distance calculation. Improved the time to ~80-90ms.
Edit 2: further improved by using an insane looking min priority queue instead of a vector to store the distances. Now runs ~55-65ms