add: day06: part1

This commit is contained in:
2025-12-08 12:30:58 +01:00
parent 1c343f5b73
commit d38a763908

17
2025/day06/part1.py Normal file
View File

@ -0,0 +1,17 @@
import math
text: str
with open("input.txt") as f:
text = f.read()
total: int = 0
lines: list[str] = text.splitlines()
numbers: list[list[int]] = [[int(nb_str) for nb_str in line.split(" ") if len(nb_str)] for line in lines[:-1]]
for i, operator in enumerate([operator for operator in lines[-1].split(" ") if len(operator)]):
if (operator == "+"):
total += sum([numbers[j][i] for j in range(len(lines) - 1)])
elif (operator == "*"):
total += math.prod([numbers[j][i] for j in range(len(lines) - 1)])
print(total)