Skip to content

Commit 56eb989

Browse files
committed
Add solution to 2025-12-02
1 parent 8723fb4 commit 56eb989

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

2025/day02/solutions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
with open("input") as f:
2+
data = f.read().strip()
3+
4+
res1 = res2 = 0
5+
6+
for l in data.split(","):
7+
start, end = l.split("-")
8+
for i in range(int(start), int(end) + 1):
9+
s = str(i)
10+
mid = len(s) // 2
11+
if len(s) % 2 == 0 and s[:mid] == s[mid:]:
12+
res1 += i
13+
if any(s == s[0:l] * (len(s) // l) for l in range(1, mid + 1)):
14+
res2 += i
15+
16+
# Part 1
17+
print(res1)
18+
19+
# Part 2
20+
print(res2)

0 commit comments

Comments
 (0)