How to Use This

Enter the Sudoku you want to solve into the form on the left. Press "set puzzle" to submit the form and register your data. When you submit the form the boxes you enter will appear as bold black text.

When the Sudoku is filled in press "solve" and the algorithm will attempt to solve the puzzle. The algorithm will fill in the boxes it can, anything else will be left blank. The boxes filled in by the algorithm will appear as blue text.

If you need to correct an entry you made use the browsers back button to go back until the form appears and change it there. If you click "set puzzle" after you have solved the solved boxes will be treated as boxes you entered and will turn to bold black.

This solver keeps a 3-dimensional array with an entry for each box in the puzzle. Dimensions 1 and 2 correspond to the row and column of the grid. Dimension 3 uses key 0 for the solution for that box, and keys 1-9 for each of the 9 possible values. Keys 1-9 start off as 1, meaning that every value is possible. When a value is ruled out for a box that value is set to 0.

When the form is set the array is updated to make the values entered the solutions for the corresponding boxes, and those values are removed from the appropriate other boxes.

From here a simple loop is entered. The loop is repeated for each individual box, row, column and quadrant of nine:

• Any values that are set are removed from all other boxes in which they could appear.
• For each object we check if there is one and only one value which is available.
• If there is a solution we fill it in, and remove that value from the other places where it can no longer be used.
• The loop is repeated until all the boxes are either solved, or a maximum of 20 iterations. I have not encountered a puzzle that has taken more than 3 iterations to solve.

While this has correctly solved every Sudoku I've given it, I can not guarantee it will work for every solvable Sudoku.