Working on search()
This commit is contained in:
parent
81e3296f6f
commit
cc5e35ff81
1 changed files with 8 additions and 0 deletions
|
@ -135,6 +135,14 @@ class Board(dict):
|
||||||
raise
|
raise
|
||||||
return self.solved
|
return self.solved
|
||||||
|
|
||||||
|
def search(self):
|
||||||
|
if self.solved:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Chose the square with the fewest possible values.
|
||||||
|
_, smallest = min((len(self[sq]), sq) for sq in self if len(self[sq]) > 1)
|
||||||
|
# Deepcopy the board.
|
||||||
|
|
||||||
def assign(self, square, value):
|
def assign(self, square, value):
|
||||||
'''
|
'''
|
||||||
Assign {value} to {square}. {value} is expected to be an iterable (a list). {key} should be a valid (x, y)
|
Assign {value} to {square}. {value} is expected to be an iterable (a list). {key} should be a valid (x, y)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue