Skip to content

consolesolver

Example module to illustrate a coupling of the solver to the console as frontend. Therefore, a corresponding Trigger and Formatter class must be implemented.

ConsoleFormatter #

Bases: BlankFormatter

Basic formatter to print the solutions steps, i.e. the partially solved puzzle, to the console. Use the flush attribute to decide whether the solution steps are stringed together in the console or if the previous step is consecutively removed.

ConsoleTrigger #

Bases: NoTrigger

Trigger that requires the user to press 'enter' to show the next solving step.

solve(sudoku, stepping, flush=False, unicode=True) #

Solve a Sudoku given as Sudoku object (possibly obtained by the load function). Use the stepping parameter to choose between the steppers 'any', to render every solving step, 'skip' to completely suppress rendering, or 'interesting' to only print more elaborate solving methods. Use the flush parameter to erase the rendered output of the previous solving step before continuing.

Parameters:

Name Type Description Default
sudoku Sudoku

The puzzle to solve

required
stepping str

Specify what solving steps to render

required
flush bool

Set to True to erase the previous solving step

False
unicode bool

Use Unicode box-drawing characters

True

Returns:

Type Description
Sudoku

The solved puzzle