Module sudoku.solvers¶
None
None
View Source
from .solver import Solver
from .strategy_solver import StrategySolver
__all__ = ("Solver", "StrategySolver")
Submodules¶
Classes¶
Solver¶
1 2 3 4 5 

View Source
class Solver(ABC):
@abstractmethod
def solve(self, puzzle: Puzzle[T]) > bool:
"""Solve the puzzle in place.
Args:
puzzle (Puzzle): The puzzle to be solved.
Returns:
bool: Whether or not the puzzle is solved.
"""
...
Ancestors (in MRO)¶
 abc.ABC
Descendants¶
 sudoku.solvers.StrategySolver
Methods¶
solve¶
1 2 3 4 

Solve the puzzle in place.
Parameters:
Name  Type  Description  Default 

puzzle  Puzzle  The puzzle to be solved.  None 
Returns:
Type  Description 

bool  Whether or not the puzzle is solved. 
View Source
@abstractmethod
def solve(self, puzzle: Puzzle[T]) > bool:
"""Solve the puzzle in place.
Args:
puzzle (Puzzle): The puzzle to be solved.
Returns:
bool: Whether or not the puzzle is solved.
"""
...
StrategySolver¶
1 2 3 4 5 

View Source
class StrategySolver(Solver):
def solve(self, puzzle: Puzzle[T]) > bool:
"""
Solve the puzzle using strategies
Returns:
bool: A boolean value indicating whether the puzzle could be solved
"""
if puzzle.has_conflicts():
return False
while not puzzle.is_solved():
changed = False
for strategy in essential_strategies(puzzle.order):
if strategy(puzzle) > 0:
changed = True
break
if not changed:
return False
return True
Ancestors (in MRO)¶
 sudoku.solvers.Solver
 abc.ABC
Methods¶
solve¶
1 2 3 4 

Solve the puzzle using strategies
Returns:
Type  Description 

bool  A boolean value indicating whether the puzzle could be solved 
View Source
def solve(self, puzzle: Puzzle[T]) > bool:
"""
Solve the puzzle using strategies
Returns:
bool: A boolean value indicating whether the puzzle could be solved
"""
if puzzle.has_conflicts():
return False
while not puzzle.is_solved():
changed = False
for strategy in essential_strategies(puzzle.order):
if strategy(puzzle) > 0:
changed = True
break
if not changed:
return False
return True