-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_handling.py
33 lines (24 loc) · 941 Bytes
/
input_handling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import os
def score(indexes_of_books, books):
result = 0
for i in indexes_of_books:
result += books[i]
return result
path_data = os.path.join("datasets", "a_example.txt") # CHECK
with open(path_data) as f:
lines = f.readlines()
n_books, n_libraries, n_days = np.asarray(lines[0].split()).astype(int)
scores_of_books = np.asarray(lines[1].split(), int)
main_dict = {idx: val for idx, val in enumerate(scores_of_books)}
line_index = 2
#libraries = {}
libraries = []
for lib_index in range(n_libraries):
libraries.append([lib_index,np.asarray(lines[line_index].split(), int),
np.asarray(lines[line_index + 1].split(), int),
score(np.asarray(lines[line_index + 1].split(), int), scores_of_books)])
line_index += 2
print(n_books, n_libraries, n_days)
print(main_dict)
print(libraries)