Skip to content

Commit 5c0a885

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

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) -> int:
8+
res = 0
9+
for remaining in range(to_choose, 0, -1):
10+
i = np.argmax(a[: len(a) - remaining + 1])
11+
res = res * 10 + a[i]
12+
a = a[i + 1 :]
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)