Sudoku is a popular puzzle (at least among train commuters in London). The object is to fill in a 9x9 grid of numbers while following a few simple rules. This set of pages grew out of my interest in producing a script that would solve them automatically (as I find doing it by hand rather tedious).
The site is divided into the following sections.
Feb 2014 - Added interactive Javascript puzzle creator.
Dec 2013 - Added interactive Javascript version.
The original 9x9 puzzle has a 9 by 9 square grid. Some squares contain numbers, most are blank. The objective is to fill in the missing numbers to complete the whole grid. There are a few constraints though:
1 | 9 | 4 | ||||||
4 | 8 | 6 | ||||||
7 | 5 | 2 | ||||||
9 | 1 | 2 | 4 | |||||
3 | ||||||||
5 | 4 | 6 | 3 | |||||
8 | 7 | 3 | ||||||
6 | 8 | 4 | ||||||
1 | 2 | 9 |
These rules are easy to generalise to other sized squares as we will see on the variants page. We can also add additional constraints, such as requiring the two diagonals to contain 1-9 too.
This is the solution to the above example where you can verify that the constraints are met. Proving that this is the only solution is a trickier problem.
2 | 6 | 8 | 7 | 1 | 9 | 3 | 4 | 5 |
1 | 3 | 4 | 8 | 2 | 5 | 6 | 9 | 7 |
7 | 5 | 9 | 3 | 6 | 4 | 1 | 8 | 2 |
3 | 9 | 7 | 1 | 8 | 2 | 5 | 6 | 4 |
6 | 4 | 2 | 9 | 5 | 3 | 7 | 1 | 8 |
5 | 8 | 1 | 4 | 7 | 6 | 2 | 3 | 9 |
8 | 2 | 5 | 6 | 4 | 1 | 9 | 7 | 3 |
9 | 7 | 6 | 5 | 3 | 8 | 4 | 2 | 1 |
4 | 1 | 3 | 2 | 9 | 7 | 8 | 5 | 6 |
(c) John Whitehouse 2013 - 2020