Next / Previous / Contents / Shipman's homepage

5.19. SudokuSolver.__xToRowCol(): Translate board position to row and column

This method translates an internal position in self.__board to row and column indices.

sudosolver.py
# - - -   S u d o k u S o l v e r . _ _ x T o R o w C o l   - - -

    def __xToRowCol ( self, x ):
        """Translate board index to row and column indices.

          [ x is an integer in [0,BOARD_L) ->
             return (r,c) where r is x's row and c is x's column ]
        """
        return divmod ( x, 9 )