We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9696c5e commit 5c0a885Copy full SHA for 5c0a885
2025/day03/solutions.py
@@ -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