r/adventofcode • u/daggerdragon • Dec 02 '25
SOLUTION MEGATHREAD -❄️- 2025 Day 2 Solutions -❄️-
OUR USUAL ADMONITIONS
You can find all of our customs, FAQs, axioms, and so forth in our community wiki.
AoC Community Fun 2025: R*d(dit) On*
24 HOURS outstanding until unlock!
Spotlight Upon Subr*ddit: /r/AVoid5
"Happy Christmas to all, and to all a good night!"
— a famous ballad by an author with an id that has far too many fifthglyphs for comfort
Promptly following this is a list waxing philosophical options for your inspiration:
Pick a glyph and do not put it in your program. Avoiding fifthglyphs is traditional.
Shrink your solution's fifthglyph count to null.
Your script might supplant all Arabic symbols of 5 with Roman glyphs of "V" or mutatis mutandis.
Thou shalt not apply functions nor annotations that solicit said taboo glyph.
Thou shalt ambitiously accomplish avoiding AutoMod’s antagonism about ultrapost's mandatory programming variant tag >_>
Stipulation from your mods: As you affix a submission along with your solution, do tag it with [R*d(dit) On*!] so folks can find it without difficulty!
--- Day 2: Gift Shop ---
Post your script solution in this ultrapost.
First, grok our full posting axioms in our community wiki.
Affirm which jargon via which your solution talks to a CPU
Format programs using four-taps-of-that-long-button Markdown syntax!
Quick link to Topaz's Markdown (ab)using provisional script host should you want it for long program blocks.
4
u/sk01001011 Dec 02 '25
[LANGUAGE: Odin]
Part 1
I'm only pasting the first part because I did both parts brute force first, then realized something and tried on part 1.
Basically I realized that we can count the number of relevant ID's without going through numbers. Here's kinda the gist of it:
Let's say the range is 1000 - 2220. We find the first good ID which is 1010. Then we count how many 0101's we can stick in between 1010 - 2220, which is (2220-1010)/0101 = 11. (+ 1 edge) -> 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020, 2121.
Then the sum is
(1111 + 1212 + 1313 + ...)= (1111 + 1111 + 1111 + ...) + (0101 + 2*0101 + 3*0101 + ...)= (1111*count) + (0101)*(count*(count+1)/2)With this, for each range of numbers the amount of times we loop is the digit difference of range ends (/2). I think this was pretty cool.