23 lines
510 B
Python
23 lines
510 B
Python
import numpy as np
|
|
|
|
LINES_NUM = 5
|
|
COLS_NUM = 1000
|
|
|
|
count = 0
|
|
|
|
probs = np.array([])
|
|
|
|
with open('input.txt', 'r') as file:
|
|
for line in file:
|
|
for num in line.split():
|
|
probs = np.append(probs, num)
|
|
|
|
probs = probs.reshape((LINES_NUM, COLS_NUM))
|
|
|
|
for col in probs.T:
|
|
if col[4] == '+':
|
|
count += int(col[0]) + int(col[1]) + int(col[2]) + int(col[3])
|
|
elif col[4] == '*':
|
|
count += int(col[0]) * int(col[1]) * int(col[2]) * int(col[3])
|
|
|
|
print(count) |