This project was a wonderful experience with recursion and deeply nested looping logic. In short it goes through every square and calculates the “pencil marks” for each square then does some functions to determine if it can derive the final number for that square. Then it does this over and over iterating over each square for the entire puzzle having picked up new squares it now knows the answer to which in turn reveals more answered squares, then these same scripts are called recursively and the whole run through the puzzle starts over again only this loop with the newly solved squares which makes that pass through able to solve more squares.
I was interested in this personal project for the following reasons.
- I used to love Sudoku puzzles.
- I thought it would be a fun experiment with recursion and nested looping.
- I haven’t refined it absolutely, but this method has to be among the faster methods for Sudoku solving and certainly would contain a minimum amount of source code.
- For commercial application this script could be combined with a game that plays Sudoku to solve puzzles the user might enter from another source or “build on their own” in order to check if there is a valid solution for that user defined Sudoku puzzle.