Sudoku Solver is a small graphical app for solving any given Sudoku puzzle, almost instantaneously. It also shows the steps required to solve the same.
(Have a look at one of the toughest Sudoku puzzles here. Sudoku Solver can solve it too, and it is the toughest one I have found till date!)
This is how Sudoku Solver looks like -
For what audience is this post intended?
Although I have primarily written this post for sharing my python code, this can be useful for you if -
- You want to learn how to solve a Sudoku puzzle by hand.
- You want to yourself make a Sudoku solving program/application.
- You want to see some large, fairly complicated, working python code.
- You don't care how the Sudoku Solver works, you just want to use it to solve some of your Sudoku puzzles.
OK, I am interested. Give me some background of Sudoku.
Sudoku is a logic based placement puzzle. A Sudoku puzzle consists of a 9 x 9 grid cells which are divided into 9 rows, columns and subgrids (as shown above). The task is to place the numbers from 1 to 9 in the empty cells in such a way that, in every row, column and 3 × 3 subgrid, each number appears only once.
How to solve a Sudoku puzzle?
Although the rules of Sudoku are quite simple, solving it can sometimes become a tough task.
I have posted this separately with lots of pictorial examples here - How To Solve A Sudoku puzzle?
I have posted this separately with lots of pictorial examples here - How To Solve A Sudoku puzzle?
So what can this program do? Show me some examples.
It can solve any Sudoku puzzle, almost instantaneously.
Example -
Take any Sudoku puzzle you like, from anywhere - newspapers, websites, etc. (For this example, I have taken the one from here.) Fill up the Sudoku Solver accordingly (How do I use the Sudoku Solver?).
Click on Solve. The puzzle will be solved instantly. Note that it shows the steps required to solve the puzzle in the side pane.
(Note the time taken to solve the puzzle - 0.05 seconds!) |
What's different in this?
Mostly on the web, you will find either of these -
- Lots of websites having tonnes of Sudoku puzzles to solve and their final answers (but they don't show the steps required to solve these puzzles).
- Some Sudoku solving apps/applets/programs, but they can solve only the simpler ones.
With my app, you can -
- Solve any Sudoku puzzle.
- Also see the steps required to solve the same.
OK, so where is the source code?
The project is hosted on GitHub (version 1.2 onwards).
If you simply wish to download the source code, see the next section.
If you simply wish to download the source code, see the next section.
How do I run/install Sudoku Solver?
- Make sure you have Python 2.7 installed.
(On Linux: sudo apt-get install python; Windows/Mac: download) - Make sure you have PyQt4 installed.
(On Linux: sudo apt-get install python-qt4; Windows/Mac: download) - Click here to download the source files. Extract it.
- Simply execute the module sudoku_solver.py in a terminal-
$ python sudoku_solver.py
To learn to use the GUI, refer to the post - Sudoku Solver - The GUI.
Coming to the programming part, how is the program structured?
The program consists of 2 parts -
- The Graphical User Interface (GUI).
- The logic required to solve (any) Sudoku puzzle.
Tell me more about the GUI.
I have fully described the Sudoku Solver GUI with pictorial examples in this post - Sudoku Solver - The GUI.
____________________________________________________
Good work! keep it up!! Saw a solution providing sudoku solver for the first time!
ReplyDeletePretty! This was an incredibly wonderful post.
ReplyDeleteThanks for providing these details. payday loans
My web site - payday loans baton rouge
Good work !! Its great work with GUI. Check out my simple code on Sudoku on http://mytechnprograms.blogspot.in/2013/03/python-code-to-solve-sudoku-puzzle.html
ReplyDeletegreat work! thanks!
ReplyDelete