-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbruteforce.py
32 lines (22 loc) · 994 Bytes
/
bruteforce.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
"""BruteForceStrategy module represents a strategy to solve Sudoku puzzles."""
import sudoku
# TODO(jakubm): Check how custom made exceptions are implemented in Py3.
class NoSolutionException(Exception):
"""Raises when Sudoku has no valid solution."""
class InvalidSudokuException(Exception):
"""Raises when Sudoku is not a valid sudoku.Sudoku object."""
class NotImplemented(Exception):
"""Raises when a functionality is not yet implemented."""
class BruteForceStrategy(object):
"""Represents a BruteForceStrategy module solving Sudoku grid."""
def __init__(self, s):
self._sudoku = None
# TODO(jakubm): Strategies accept only sudoku.Sudoku objects.
# if isinstance(s, sudoku.Sudoku).
self._sudoku = s
# else:
# raise InvalidSudokuException(
# 'Provided sudoku grid is not sudoku.Sudoku object.')
def solve(self):
"""Applies bruteforce algorithm to solve Sudoku."""
raise NotImplemented('solve method is not yet implemented.')