Next / Previous / Contents / Shipman's homepage

5.13. SudokuSolver.__solution(): Signal a solution

This method is called when the puzzle has been solved. It has two jobs: call the solution observer callback, and increment the number of solutions found.

sudosolver.py
# - - -   S u d o k u S o l v e r . _ _ s o l u t i o n   - - -

    def __solution ( self ):
        """A solution has been found.

          [ if self.solutionObserver is not None ->
              call self.solutionObserver(self)
            in any case ->
              self.nSolutions  +:=  1 ]
        """

        #-- 1 --
        self.nSolutions  +=  1

        #-- 2 --
        if  self.solutionObserver is not None:
            self.solutionObserver(self)