forked from Berkeley-CS170/project-fa20-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver.py
44 lines (36 loc) · 1.29 KB
/
solver.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
import networkx as nx
from parse import read_input_file, write_output_file
from utils import is_valid_solution, calculate_happiness
import sys
from os.path import basename, normpath
import glob
def solve(G, s):
"""
Args:
G: networkx.Graph
s: stress_budget
Returns:
D: Dictionary mapping for student to breakout room r e.g. {0:2, 1:0, 2:1, 3:2}
k: Number of breakout rooms
"""
pass
# Here's an example of how to run your solver.
# Usage: python3 solver.py test.in
# if __name__ == '__main__':
# assert len(sys.argv) == 2
# path = sys.argv[1]
# G, s = read_input_file(path)
# D, k = solve(G, s)
# assert is_valid_solution(D, G, s, k)
# print("Total Happiness: {}".format(calculate_happiness(D, G)))
# write_output_file(D, 'outputs/small-1.out')
# For testing a folder of inputs to create a folder of outputs, you can use glob (need to import it)
# if __name__ == '__main__':
# inputs = glob.glob('inputs/*')
# for input_path in inputs:
# output_path = 'outputs/' + basename(normpath(input_path))[:-3] + '.out'
# G, s = read_input_file(input_path)
# D, k = solve(G, s)
# assert is_valid_solution(D, G, s, k)
# happiness = calculate_happiness(D, G)
# write_output_file(D, output_path)