What is this
- 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.
- 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
Some comments on recursion
- Backtracking during a ‘brute force’ solution. This would happen when we run out of options for trying out a value in a box, so need to go backwards until we find an alternative arrangement of numbers that allow us to go right through to a solution
- Backtracking during a ‘strategy solve’. Since we are planning to generate puzzles according to their difficulty, we have to ensure that we exhaust all the easier strategies first. That means that if we resort to a more complex strategy to solve a particular cell, we need to backtrack to apply the result of the newly solved cell to each of the other cells using the easier strategies again.
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas – from VBA to Apps script, All formats are available from O’Reilly, Amazon and all good bookshops. You can also read a preview on O’Reilly