Skip to content

Commit d2b12f9

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

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

2025/day06/solutions.py

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

0 commit comments

Comments
 (0)