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 c865029Copy full SHA for c865029
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):
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