-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution_validator.py
More file actions
56 lines (36 loc) · 1.91 KB
/
Copy pathsolution_validator.py
File metadata and controls
56 lines (36 loc) · 1.91 KB
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
def check_out_file(prefix, filename, nr_pizzas, teams_of_2, teams_of_3, teams_of_4):
with open(prefix + filename, "r") as fin:
nr_deliveries = int(fin.readline().strip())
# Number of deliveries should be a positive integer
assert(nr_deliveries > 0)
pizzas_used = set()
for _ in range(nr_deliveries):
delivery = fin.readline().strip().split(" ")
nr_pizzas_in_del = int(delivery[0])
# There should be 2, 3, or 4 pizzas in a delivery
assert(nr_pizzas_in_del >= 2 and nr_pizzas_in_del <= 4)
# Making sure that a pizza never appears twice
for pizza in delivery[1:]:
appears = False
if int(pizza) in pizzas_used:
appears = True
assert(appears == False)
pizzas_used.add(int(pizza))
input_files = ["a_example.in", "b_little_bit_of_everything.in", "c_many_ingredients.in", "d_many_pizzas.in", "e_many_teams.in"]
for input_file in input_files:
with open("input_files/" + input_file, "r") as fin:
first_line = fin.readline()
info = first_line.strip().split(" ")
# Read the general information
nr_pizzas = int(info[0])
teams_of_2 = int(info[1])
teams_of_3 = int(info[2])
teams_of_4 = int(info[3])
print("Now checking for dataset " + input_file)
output_file = input_file.split(".")[0] + ".out"
print("\tChecking for sol1")
check_out_file("output_files/sol1/", output_file, nr_pizzas, teams_of_2, teams_of_3, teams_of_4)
print("\tAll is good")
print("\tChecking for sol2")
check_out_file("output_files/sol2/", output_file, nr_pizzas, teams_of_2, teams_of_3, teams_of_4)
print("\tAll is good")