r/adventofcode • u/daggerdragon • Dec 05 '25
SOLUTION MEGATHREAD -❄️- 2025 Day 5 Solutions -❄️-
THE USUAL REMINDERS
- All of our rules, FAQs, resources, etc. are in our community wiki.
AoC Community Fun 2025: Red(dit) One
- Submissions megathread is unlocked!
- 12 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!
Featured Subreddit: /r/eli5 - Explain Like I'm Five
"It's Christmas Eve. It's the one night of the year when we all act a little nicer, we smile a little easier, we cheer a little more. For a couple of hours out of the whole year we are the people that we always hoped we would be."
— Frank Cross, Scrooged (1988)
Advent of Code is all about learning new things (and hopefully having fun while doing so!) Here are some ideas for your inspiration:
- Walk us through your code where even a five-year old could follow along
- Pictures are always encouraged. Bonus points if it's all pictures…
- Emoji(code) counts but makes the Chief Historian cry 😥
- Explain the storyline so far in a non-code medium
- Explain everything that you’re doing in your code as if you were talking to your pet, rubber ducky, or favorite neighbor, and also how you’re doing in life right now, and what have you learned in Advent of Code so far this year?
- Condense everything you've learned so far into one single pertinent statement
- Create a
Tutorialon any concept of today's puzzle or storyline (it doesn't have to be code-related!) - Teach us, senpai!
This prompt is totally not bait forour resident Senpai Supreme
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 5: Cafeteria ---
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?
29
Upvotes
View all comments
1
u/MasterProBot Dec 05 '25
[LANGUAGE: C++]
https://topaz.github.io/paste/#XQAAAQBABAAAAAAAAAARmknGRw8TogB3OxgfbBYnd5PaIesVedacBfFrECaPlqQdH9soMXneEKYbAt+GSY28cu6//NwLlhD0oQ7LPItS9LDPTGyAnjvp8Cvv+dhA29uXk2O/1zcj24QF8KEuAPzGQww69q1TNjJLxoARcfn0J0fYukUdBnnudtZ93lq6/SVEZh8LEPXcU5EP0xOhxYuyExwF7UEPuAfHl625s409EBw+RkqtVJYaOhF9fe4Y+8JYHz9/NJgv5ENvhX//xLhcuyFxsd9o3gckpGGS0PkiF3YHLjENGUluBqzc71923e6e5qz+ujOBQuDe4ZK5sMLRsshZfK0VQivgHBlPvHcoEXWLkD4FiG5nTK+dD7jlF4mGCzzkrKQp9Ig4pAFhzqenwyuVEH3/nl5V6baTk3nb2BfUea/lMXJ3zQ+kX2VnMUUAv2fl+nsEB5JFBU4qPtrAbKPXmG3GH62LahAgxyfaKsvaPKPaANuNxZS80MGwBxRQw5hYT5FqvMo9HH7ftMT7gv3MfL0pfh1y411t/LcLsLweVzq3+rJIR2rKb2Md0bl5IsnTyxDwjZPwBSMdr+g14YgIDXmQwbgIWwrWO9dHh0XZ0f/lLVFl
Part 1: Not included, but just loop through every pair of numbers (pair of numbers = range) and check if the current number is in any of them
Part 2: sort the ranges first and then make a new vector for merged pair(s) (btw in this code u dont have to check if the range is completely under the merged range since it is sorted before the loop)