this time with no legal info
This commit is contained in:
23
6/ex1.py
Normal file
23
6/ex1.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user