aboutsummaryrefslogtreecommitdiff
path: root/2025/06/a.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-06 07:57:16 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-06 07:57:16 +0100
commitbe683b101393d3566261c9cc10351398bd2e1b6c (patch)
treeb8c47ad943a4f5cffd423ee04f6a931c4b276b89 /2025/06/a.py
parent424ffd61c58eb127f9a657a854737e2d82368217 (diff)
downloadaoc-be683b101393d3566261c9cc10351398bd2e1b6c.tar.gz
aoc-be683b101393d3566261c9cc10351398bd2e1b6c.zip
Day 6 2025 I suck
Diffstat (limited to '2025/06/a.py')
-rw-r--r--2025/06/a.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/2025/06/a.py b/2025/06/a.py
index 5fdb11b..1d12e01 100644
--- a/2025/06/a.py
+++ b/2025/06/a.py
@@ -1,6 +1,20 @@
1import fileinput 1import fileinput
2from functools import reduce
3from operator import mul
2 4
5a = []
6op = []
3with fileinput.input() as lines: 7with fileinput.input() as lines:
4 for line in lines: 8 for line in lines:
5 ... 9 t = line[:-1].split(' ')
10 if t[0] == '+' or t[0] == '*':
11 op = [x for x in t if x != '']
12 else:
13 a.append([int(x) for x in t if x != ''])
6 14
15def sol(a, op, i):
16 return (sum(a[j][i] for j in range(len(a))) if op[i] == '+'
17 else reduce(mul, (a[j][i] for j in range(len(a))), 1))
18
19
20print(sum(sol(a, op, i) for i in range(len(a[0]))))

Generated with cgit - Back to sebastiano.tronto.net