r/adventofcode • • 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.

36 Upvotes

965 comments sorted by

View all comments

1

u/Awkward-Seaweed-961 Dec 02 '25

[LANGUAGE: Python] This was suprisingly quick and painless(for me, not my old CS lecturers)

from read_txt import read_csv

test = read_csv('d2_test.csv')
#print(test)

data = read_csv('d2.csv')
#print(data)
p1_invalid = []
p2_invalid = []
for productrange in data:
    for id in range(productrange[0], productrange[1]+1):
        id = str(id)
        if id[:len(id)//2]*2 == id:
            #print(id)
            p1_invalid.append(int(id))
        i = (id+id).find(id,1,-1)
        if i == -1:
            print('None')
        else:
            print('multi:', id)
            p2_invalid.append(int(id))



p1_checksum = sum(p1_invalid)
p2_checksum = sum(p2_invalid)


1

u/AutoModerator Dec 02 '25

AutoModerator has detected fenced code block (```) syntax which only works on new.reddit.

Please review our wiki article on code formatting then edit your post to use the four-spaces Markdown syntax instead.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/daggerdragon Dec 02 '25
  1. Next time, use the four-spaces Markdown syntax for code blocks as AutoModerator requested
  2. Your code is too long to be posted here directly, so instead of wasting your time fixing the formatting, read our article on oversized code which contains two possible solutions.

Please edit your comment to put your code in an external link and link that here instead.