-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasesolver.py
More file actions
28 lines (22 loc) · 891 Bytes
/
basesolver.py
File metadata and controls
28 lines (22 loc) · 891 Bytes
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
from .parsing import parse_input, write_output
from .scoring import compute_score
class BaseSolver(object):
"""Don't touch this!
This class makes sure that those two methods gets implemented,
as needed in main.py.
"""
def __init__(self, input_str):
"""Initialisation of the given problem.
"""
self.input_str = input_str
self.data = parse_input(self.input_str)
self.solution = []
def solve(self):
"""Solves the problem and stores the solution internally.
:return: True, if a solution is found, False otherwise
"""
raise NotImplementedError("This method needs to be implemented.")
def write(self, output_str):
write_output(output_str, self.solution)
s = compute_score(self.input_str, output_str)
print("Score for {}: {} points".format(self.input_str, s.total()))