Skip to content

Commit d9baf00

Browse files
committed
Add solution to 2025-12-06
1 parent 887cec2 commit d9baf00

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

2025/day06/solutions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from math import prod
2+
3+
with open("input") as f:
4+
*num_lines, ops_line, _ = f.read().split("\n")
5+
6+
indices = [i for i, x in enumerate(ops_line) if x != " "]
7+
ops = [{"+": sum, "*": prod}[ops_line[i]] for i in indices]
8+
9+
# Part 1
10+
nums1 = [
11+
[line[start : end - 1] for line in num_lines]
12+
for start, end in zip(indices, indices[1:] + [len(ops_line) + 1])
13+
]
14+
15+
# Part 2
16+
nums2 = [map("".join, zip(*ns)) for ns in nums1]
17+
18+
for nums in (nums1, nums2):
19+
print(sum(op(map(int, col)) for op, col in zip(ops, nums)))

0 commit comments

Comments
 (0)