Next / Previous / Contents / Shipman's homepage

5.8. SudokuSolver.__rowColToX(): Convert row and column to board position

This method converts a cell position as a row and column index to the corresponding position in the self.__board list.
# - - -   S u d o k u S o l v e r . _ _ r o w C o l T o X   - - -

    def __rowColToX ( self, r, c ):
        """Convert row/column indices to board index.

          [ r and c are integers in [0,8] ->
              return the index in self.__board corresponding to
              that row and column ]
        return  ( r * MAT_L ) + c

There is no trace table for this method. Verification is by inspection. The transforms between (row,column) and indices in self.__board are discussed in Section 5.3, “class SudokuSolver.