22 lines
451 B
Python
22 lines
451 B
Python
from functools import reduce
|
|
from operator import mul
|
|
|
|
|
|
with open("input", "r") as f:
|
|
lines = f.read().splitlines()
|
|
|
|
lines = [line.split() for line in lines]
|
|
|
|
transposed = [[lines[j][i] for j in range(len(lines))] for i in range(len(lines[0]))]
|
|
|
|
s = 0
|
|
|
|
for line in transposed:
|
|
operands, operator = list(map(int, line[:-1])), line[-1]
|
|
if operator == "+":
|
|
s += sum(operands)
|
|
else:
|
|
s += reduce(mul, operands, 1)
|
|
|
|
print(s)
|