Page Content

#### What is this

These few pages are about how to create a Sudoku Solver and Generator using Excel/VBA. If you just want one, then go ahead and download it. If you are interested in how to write a solver and generator, then read on.
Here is the finished Sudoku Generator and solver.

#### Design considerations

You will all be be familiar with Sudoku, and no doubt have seen the thousands of solvers, and rather less generators around. I’ve seen a few in Excel also, but not that many. What we are going to do is write one from scratch, and make heavy use of both Classes and Recursion. The files available from the downlable section will reflect progress made so far, and hopefully, eventually a fully functioning solver and generator. I’m calling it ExcelDoku as a working name- any suggestions are welcome. As usual the complete project is downloadable from the downloads page.
This is going to be a fairly complex problems because we are going to do the following
• Deal with sudokus of any shape  up to 4 x 4.  r x c refers to the number of rows and columns in a Box. The usual Sudoku is 3 x 3 and consists of of 81 cells. We will allow odd shapes like 2 x 5 and so on, since it is easier to generalize that from the start than to try to retrofit.
• Generate genuine puzzles, on the fly,  which can be solved by human sudoku strategies – ie. not by ‘brute force trial and error
• Allow generation to a target level of difficulty – easy, medium, hard, diabolical – where the difficulty is based on the complication of the strategies required to solve, rather than just the number of starting cells.

#### Implementation considerations

The capabilities a solver and generator like this needs are as follows
• Solve puzzles using human Sudoku Strategies
• Solve puzzles using ‘brute force’ in order to be able to generate skeleton puzzles – this is essentially solving a ‘blank puzzle’
• User interface to show solved puzzles, allow interactive solving, show pencil marks, select options, enter custom puzzles, and show generated puzzles
In terms of priority, our first priority is to create a basic solver – since this is needed to help generate and to validate generated puzzles. The user interface will be kept skeletal until we have a solid solver and generator, especially since our objective is to demonstrate recursion in the first instance.