-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
61 lines (46 loc) · 1.92 KB
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import argparse
from Parser import Parser
from model.result_values import ResultValue
import scoring
def show_banner():
with open("banner.txt", "r", encoding="utf-8") as f:
for line in f.readlines():
print(line[:-1])
def get_args():
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("input", help="Input file")
args = arg_parser .parse_args()
return args.input
if __name__ == '__main__':
show_banner()
path_to_input_file = get_args()
# Parsing
print("Parsing solution from file ", path_to_input_file)
parser = Parser(path_to_input_file)
map_value = parser.parse()
# Solving
print("Solving solution for ", path_to_input_file.split(".")[0])
result_value = ResultValue()
libraries = list(map_value.libraries.values())
remaining_days_before_next_library_submission = 0
last_elected_library = None
submited_libraries = []
for day_number in range(map_value.total_scanning_day):
print(day_number)
if len(libraries) == 0:
pass
# Si on peut soumettre une nouvelle library
elif remaining_days_before_next_library_submission == 0:
# On recalcule efficiency pour chaque library et on trie les library
for library in libraries:
library.efficiency = scoring.efficiency_library(library, map_value.total_scanning_day - day_number)
libraries.sort(key=lambda x: x.efficiency, reverse=True)
last_elected_library = libraries[0]
remaining_days_before_next_library_submission = last_elected_library.sign_up_days
result_value.add_library(last_elected_library)
libraries = libraries[1:]
for library in libraries:
library.remove_list_books(last_elected_library.book_list)
remaining_days_before_next_library_submission -= 1
# Write output
result_value.write_result(path_to_input_file)