Primary focus of this blog entry is to demonstrate some of the power and flexibility offered by object orientated programming and design patterns. I will try to demonstrate these techniques and how to use them to solve complex problems like Sudoku.
I chose Sudoku rather than "Hello world" because it's fun, complex and seems like all the rage at the moment.
I have divided this entry in to multiple parts for the benefit of all.
Part 1 is for people who are only interested in acquiring a free Sudoku solver but don't necessarily give a damn about any of the programming techniques mentioned above.
Part 2 is for those who are interested in knowing the different techniques and logic used to solve the problem and some statistics and pros and cons of each method.
Part 3 will be for developers who are interested into the actual code walkthrough.
Well without any further babble I will describe the usage of the Sudoku solver.
The main screen of Sudoku Solver
Starting a new sudoku.
- Click on New menu item and it will pop up the following dialog box
- Choose the required grid size (9 X 9 is the standard size).
- Choose the solving strategy (quick solver possible vals is the fastest one).
- Tick the populate sample data check box if you want to populate a sample sudoku.
- Click OK button.
Now you will have a sudoku on the main screen as shown before.
Click on any blank cell you want to put a value in and it will show you a drop down box with values as shown below
Select a value and it will be placed in that cell.
Solving sudoku
Once you have finished placing all the values click on the Solve menu item to solve the sudoku.
The tool will solve any sudoku with a valid solution.
Restarting a Sudoku.
If you want to start a new sudoku based on the same grid and solving strategy then click on Reset menu else start over a new sudoku based on new options by clicking on New menu item again.
More...
You can also use this tool as a sudoku generator by placing just a couple of random values and clicking solve button.
Any grid bigger than 25 X 25 will be pure academic and with no fun value to the sudoku fans. So I have restricted it to that size through UI but for the benefit of the geeks the underlying code is made capable of solving sudoku of any grid size and is only restricted by the memory and processing power.
You can download the zip file for this sudoku solver at the end of this post. Please note that you will need .NET 2 runtime on your machine in order to run this programme. If you dont have it then you can download it from Microsoft website here.