def __init__(self, mat):
        '''
        Create a new Sudoku instance.
        mat -- 9x9 array of digits 1-9
               or None if no value is known for that spot
        '''
        self.mat = mat

        # keep track of all values used in each row, column and sub-matrix.
        rows = [[] for i in range(9)]
        cols = [[] for i in range(9)]
        subs = [[] for i in range(9)]
        
        for row_i in range(9):
            for col_i in range(9):
                v = self.mat[row_i][col_i]
                uniqueInsert(rows[row_i], v)
                uniqueInsert(cols[col_i], v)
        for srow_i in range(3):
            for scol_i in range(3):
                sub = self.submat(srow_i, scol_i)
                for i in range(3):
                    for j in range(3):
                        v = sub[i][j]
                        sub_i = srow_i * 3 + scol_i
                        uniqueInsert(subs[sub_i], v)
        self.rows = rows
        self.cols = cols
        self.subs = subs

        Create a new Sudoku instance.
        mat -- 9x9 array of digits 1-9
               or None if no value is known for that spot
        
recipes/Python/440542_Sudoku_Solver/recipe-440542.py