I was talking with my brother about Sudoku puzzles and it occurred to me that I could actually make a program that would take input from a user (into either a text box, combo box or a numeric up down) on a windows form in a 9X9 grid, and the program would solve the puzzle for them. Now as a quick disclaimer I do not know much about solving Sudoku puzzles so there are probably better algorithms out there but this is the best way that I can think of.

The basic premise of the idea is based off of a lock. There are locks out there that have a set of cylinder that have 10 “faces” on them, containing the numbers from 0 to 9. The lock then opens when the correct combination of numbers is “selected”. Now, there was a lock like this at the house one day and I wanted to find what the combo was. So what I did was set all 4 to “0″. Then I tested to see if 0-0-0-0 was indeed the combo, as expected it wasn’t. I then bumped the right most number from 0 to 1, setting the overall combo to 0-0-0-1, and then tested to see if that would open the lock. When that was not the combo either I then bumped that upper most number from 1 to 2 leaving the combo at 0-0-0-2. The process is repeated until the right most number is reset to 0 then the second from the right cylinder was bumped from 0 to 1 (leaving the combo at 0-0-1-0) and was then again tested to see if that was indeed the combo. When that was not the combo we then take the right most cylinder and bump it up to 1 (leaving the combo at 0-0-1-1) and then when that didn’t work bump it up to 2. This process is repeated until the correct combo is found. Where the right most number is bumped up by 1 and then tested, and then when it comes back to 0 the one to the left is bumped up 1 and if that is reset to 0 the one to it’s left is bumped up by 1 and then when that is reset to 0 bump the left most.

Now imagine if all of the squares in a Sudoku Puzzle that were not given a value when the puzzle was started are in one huge lock, with each number being their own individual cylinder on the lock. Then you have the computer run through all of the tedious bumping up by 1 and then checking to see if it indeed the solution to the puzzle.

—-

Today’s guest post is written by Kirk Saunders. I am a sophomore Computer Science major at Anderson University in Anderson, IN. You can read his new blog and interact with him! There will eventually be more updates on the progress and notes on the project.