advent of code 2025
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

add day 2

Kot d46a294a 9a442811

+24
+23
2.py
··· 1 + import sys 2 + import math 3 + 4 + repeated_twice = 0 5 + repeated_n = 0 6 + file = '2.input' if len(sys.argv) <= 1 else sys.argv[1] 7 + for pair in open(file).readline().split(","): 8 + start, end = pair.split("-") 9 + for i in range(int(start), int(end) + 1): 10 + n = int(math.log10(i)) + 1 11 + for length in range(n // 2, 0, -1): 12 + div, rem = divmod(n, length) 13 + if rem != 0: 14 + continue 15 + repeated = div * str(i)[:length] 16 + if int(repeated) == i: 17 + repeated_n += i 18 + if div == 2: 19 + repeated_twice += i 20 + break 21 + 22 + print(f'p1: {repeated_twice}') 23 + print(f'p2: {repeated_n}')
+1
2.test
··· 1 + 11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124