r/adventofcode • • Dec 03 '25

SOLUTION MEGATHREAD -❄️- 2025 Day 3 Solutions -❄️-

DO NOT SHARE PUZZLE TEXT OR YOUR INDIVIDUAL PUZZLE INPUTS!

I'm sure you're all tired of seeing me spam the same ol' "do not share your puzzle input" copypasta in the megathreads. Believe me, I'm tired of hunting through all of your repos too XD

If you're using an external repo, before you add your solution in this megathread, please please please 🙏 double-check your repo and ensure that you are complying with our rules:

If you currently have puzzle text/inputs in your repo, please scrub all puzzle text and puzzle input files from your repo and your commit history! Don't forget to check prior years too!


NEWS

Solutions in the megathreads have been getting longer, so we're going to start enforcing our rules on oversized code.

Do not give us a reason to unleash AutoModerator hard-line enforcement that counts characters inside code blocks to verify compliance… you have been warned XD


THE USUAL REMINDERS


AoC Community Fun 2025: Red(dit) One

  • Submissions megathread is now unlocked!
  • 14 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!

Featured Subreddit: /r/thingsforants

"Just because you can’t see something doesn’t mean it doesn’t exist."
— Charlie Calvin, The Santa Clause (1994)

What is this, a community for advent ants?! Here's some ideas for your inspiration:

  • Change the font size in your IDE to the smallest it will go and give yourself a headache as you solve today's puzzles while squinting
  • Golf your solution
    • Alternatively: gif
    • Bonus points if your solution fits on a "punchcard" as defined in our wiki article on oversized code. We will be counting.
  • Does anyone still program with actual punchcards? >_>
  • Solve today's puzzles using an Alien Programming Language APL or other such extremely dense and compact programming language

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 3: Lobby ---


Post your code solution in this megathread.

38 Upvotes

964 comments sorted by

View all comments

1

u/jcastroarnaud Dec 03 '25 edited Dec 04 '25

[LANGUAGE: JavaScript]

This day 3 was fun to figure out. At once I noticed that the largest 2-digit number would have the largest possible digit at left - except that the largest digit could be the last. I had to make a special case of it: if the largest digit is the last, find the largest digit to the left of it to complete the number.

Then part 2 forced me to tackle the general problem, 12 digits instead of 2. That was the fun part. Relevant code below.

Total time spent: about 40 minutes to solve, another 15 minutes to pretty out the code and post here.

Edit: Replaced the code with the module's full code.

1

u/daggerdragon Dec 03 '25

Relevant code below.

Top-level comments in Solution Megathreads are for code solutions only.

The rest of the stuff can stay, but we need to see the full code too.

Edit your comment to include your full code, not just "the relevant part".

Hint: your code block is long enough that you should re-read the OP of this post.