(self, c)
Solve the problem using the currently-entered values
Solve the problem using the currently-entered values
Solve the problem using the currently - entered values
def solve(self, c):
        """Solve the problem using the currently-entered values"""
        sq_size = self.size**2


        # First, we compute the user constraints to feed into the Sudoku solver
        constraints = []
        for i in range(sq_size):
            row = []
            for j in range(sq_size):
                txt = self.table[i][j].get_text()
                try:
                    n = int(txt)
                except ValueError:
                    n = 0
                row.append(n)
            constraints.append(row)

        # Solve the problem
        result = self.sudoku.solve(constraints)

        if result is not None:
            # Show the result
            for r, lst in enumerate(result):
                for c, val in enumerate(lst):
                    self.table[r][c].set_text(str(val))

        else:
            # The problem is unsolvable, show a message
            dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO,
                                       Gtk.ButtonsType.OK,
                                       "The problem is unsolvable!")
            dialog.run()
            dialog.destroy()
def solve ( self , c ) : sq_size = self . size ** 2 # First, we compute the user constraints to feed into the Sudoku solver constraints = [ ] for i in range ( sq_size ) : row = [ ] for j in range ( sq_size ) : txt = self . table [ i ] [ j ] . get_text ( ) try : n = int ( txt ) except ValueError : n = 0 row . append ( n ) constraints . append ( row ) # Solve the problem result = self . sudoku . solve ( constraints ) if result is not None : # Show the result for r , lst in enumerate ( result ) : for c , val in enumerate ( lst ) : self . table [ r ] [ c ] . set_text ( str ( val ) ) else : # The problem is unsolvable, show a message dialog = Gtk . MessageDialog ( self , 0 , Gtk . MessageType . INFO , Gtk . ButtonsType . OK , "The problem is unsolvable!" ) dialog . run ( ) dialog . destroy ( )