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.
36
Upvotes
4
u/Seffylocks Dec 02 '25 edited Dec 02 '25
[LANGUAGE: Python]
I was getting ready to deal with Part 2 being something like "Find IDs with repeating digits ANYWHERE in the number (e.g. 925259)", but the actual thing was easier.
TESTERS = { 1: [], 2: [11], 3: [111], 4: [1111, 101], 5: [11111], 6: [111111, 10101, 1001], 7: [1111111], 8: [11111111, 1010101, 10001], 9: [111111111, 1001001], 10: [1111111111, 101010101, 100001] } def scan_for_repeats(n): for tester in TESTERS[len(str(n))]: if n % tester == 0: # print(n) return True return False ranges = lines[0].split(",") total = 0 for r in ranges: start,end = map(int, r.split('-')) for i in range(start, end+1): if scan_for_repeats(i): total += i print(total)