From be683b101393d3566261c9cc10351398bd2e1b6c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 6 Dec 2025 07:57:16 +0100 Subject: Day 6 2025 I suck --- 2025/06/a.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to '2025/06/a.py') 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 @@ import fileinput +from functools import reduce +from operator import mul +a = [] +op = [] with fileinput.input() as lines: for line in lines: - ... + t = line[:-1].split(' ') + if t[0] == '+' or t[0] == '*': + op = [x for x in t if x != ''] + else: + a.append([int(x) for x in t if x != '']) +def sol(a, op, i): + return (sum(a[j][i] for j in range(len(a))) if op[i] == '+' + else reduce(mul, (a[j][i] for j in range(len(a))), 1)) + + +print(sum(sol(a, op, i) for i in range(len(a[0])))) -- cgit v1.3