Skip to content

Commit e08678f

Browse files
committed
Added day 2
1 parent 9a5aec0 commit e08678f

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

aoc/2025/02/normal/02_normal.vn.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
# Advent of code Day 02
22
# https://adventofcode.com/2025/day/02
33
# 02/12/2025
4-
4+
5+
from tqdm.auto import tqdm
6+
7+
with open("input.txt") as f:
8+
inp = list(
9+
map(
10+
lambda l: tuple(map(int, l.split("-"))),
11+
f.readlines()[0].strip().split(","))
12+
)
13+
14+
15+
res1 = 0
16+
res2 = 0
17+
for l, r in tqdm(inp):
18+
for n in range(l, r + 1):
19+
s = str(n)
20+
s1 = s[:len(s)//2]
21+
s2 = s[len(s)//2:]
22+
if s1 == s2:
23+
res1 += n
24+
25+
for p in range(1, len(s)//2 + 3):
26+
if s == s[:p] * (len(s) // p):
27+
res2 += n * (p != len(s))
28+
break
29+
30+
31+
print(res1, res2)

0 commit comments

Comments
 (0)