(self, logic, solver_name=None)
return solver, var_table
Returns a solver initialized with the sudoku constraints and a
        matrix of SMT variables, each representing a cell of the game.
Returns a solver initialized with the sudoku constraints and a
        matrix of SMT variables, each representing a cell of the game.
Returns a solver initialized with the sudoku constraints and a matrix of SMT variables each representing a cell of the game .
def get_prepared_solver(self, logic, solver_name=None):
        """Returns a solver initialized with the sudoku constraints and a
        matrix of SMT variables, each representing a cell of the game.
        """
        sq_size = self.size**2
        ty = self.get_type()
        var_table = [[FreshSymbol(ty) for _ in range(sq_size)]
                          for _ in range(sq_size)]

        solver = Solver(logic=logic, name=solver_name)
        # Sudoku constraints
        # all variables are positive and lower or equal to than sq_size
        for row in var_table:
            for var in row:
                solver.add_assertion(Or([Equals(var, self.const(i))
                                         for i in range(1, sq_size + 1)]))

        # each row and each column contains all different numbers
        for i in range(sq_size):
            solver.add_assertion(AllDifferent(var_table[i]))
            solver.add_assertion(AllDifferent([x[i] for x in var_table]))

        # each square contains all different numbers
        for sx in range(self.size):
            for sy in range(self.size):
                square = [var_table[i + sx * self.size][j + sy * self.size]
                          for i in range(self.size) for j in range(self.size)]
                solver.add_assertion(AllDifferent(square))

        return solver, var_table
def get_prepared_solver ( self , logic , solver_name = None ) : sq_size = self . size ** 2 ty = self . get_type ( ) var_table = [ [ FreshSymbol ( ty ) for _ in range ( sq_size ) ] for _ in range ( sq_size ) ] solver = Solver ( logic = logic , name = solver_name ) # Sudoku constraints # all variables are positive and lower or equal to than sq_size for row in var_table : for var in row : solver . add_assertion ( Or ( [ Equals ( var , self . const ( i ) ) for i in range ( 1 , sq_size + 1 ) ] ) ) # each row and each column contains all different numbers for i in range ( sq_size ) : solver . add_assertion ( AllDifferent ( var_table [ i ] ) ) solver . add_assertion ( AllDifferent ( [ x [ i ] for x in var_table ] ) ) # each square contains all different numbers for sx in range ( self . size ) : for sy in range ( self . size ) : square = [ var_table [ i + sx * self . size ] [ j + sy * self . size ] for i in range ( self . size ) for j in range ( self . size ) ] solver . add_assertion ( AllDifferent ( square ) ) return solver , var_table