-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpuzzle.py
41 lines (32 loc) · 977 Bytes
/
puzzle.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
class Puzzle:
""""
Snapshot of a full-information puzzle, which may be solved, unsolved,
or even unsolvable.
"""
def fail_fast(self):
"""
Return True iff Puzzle self can never be extended to a solution.
Override this in a subclass where you can determine early that
this Puzzle can't be solved.
@type self: Puzzle
@rtype: bool
"""
return False
def is_solved(self):
"""
Return True iff Puzzle self is solved.
This is an abstract method that must be implemented
in a subclass.
@type self: Puzzle
@rtype: bool
"""
raise NotImplementedError
def extensions(self):
"""
Return list of legal extensions of Puzzle self.
This is an abstract method that must be implemented
in a subclass.
@type self: Puzzle
@rtype: list[Puzzle]
"""
raise NotImplementedError