19 lines
No EOL
402 B
Python
19 lines
No EOL
402 B
Python
def mult(a,b):
|
|
return a*b
|
|
|
|
def add(a,b):
|
|
return a+b
|
|
|
|
with open(r'day6/input.txt', 'r') as input:
|
|
lines = list(map(lambda x: x.split(), input.read().split('\n')[:-1]))
|
|
|
|
sum = 0
|
|
|
|
for i in range(len(lines[0])):
|
|
op = add if lines[-1][i] == '+' else mult
|
|
res = int(lines[0][i])
|
|
for j in range(1,len(lines)-1):
|
|
res = op(res,int(lines[j][i]))
|
|
sum += res
|
|
|
|
print(sum) |