Skip to content

Commit c865029

Browse files
committed
Add solution to 2025-12-03
1 parent 9696c5e commit c865029

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

2025/day03/solutions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import numpy as np
2+
3+
with open("input") as f:
4+
ls = f.read().strip().split("\n")
5+
6+
7+
def greedy_largest_substr(a, to_choose):
8+
res = 0
9+
i = -1
10+
for remaining in range(to_choose, 0, -1):
11+
i += np.argmax(a[i + 1 : len(a) - remaining + 1]) + 1
12+
res = res * 10 + a[i]
13+
return res
14+
15+
16+
for to_choose in (2, 12):
17+
print(sum(greedy_largest_substr(list(map(int, l)), to_choose) for l in ls))

0 commit comments

Comments
 (0)