-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.py
More file actions
40 lines (33 loc) · 1.12 KB
/
checker.py
File metadata and controls
40 lines (33 loc) · 1.12 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
from dimacs import *
import os
from time import time
def check(f, name = ''):
dir = os.listdir("graphs-lab3")
for i in range(len(dir)):
if dir[i] == "grid100x100":
dir[i], dir[-1] = dir[-1], dir[i]
break
i = 0
a = time()
if len(name) > 0:
n, E = loadWeightedGraph("graphs-lab3/" + name)
result = f(E)
sol = int(readSolution("graphs-lab3/" + name))
if result == sol:
print("Test " + str(i) + ": Passed")
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(result) + ", should be: " + str(sol))
i += 1
print("Time: " + str(time() - a) + " s")
return
for graph in dir:
print(graph)
n, E = loadWeightedGraph("graphs-lab3/" + graph)
result = f(E)
sol = int(readSolution("graphs-lab3/" + graph))
if result == sol:
print("Test " + str(i) + ": Passed")
else:
print("Test " + str(i) + ": WRONG answer, result = " + str(result) + ", should be: " + str(sol))
i += 1
print("Time: " + str(time() - a) + " s")