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 Problem

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. Every row must contain each of the numbers 1-9 exactly once.
  2. Every column must contain each of the numbers 1-9 exactly once.
  3. Each of the nine 3x3 sub-sections (highlighted in the example below using a checkerboard shading pattern) must contain each of the numbers 1-9 exactly once.
    19 4 
  48  6  
75      2
 9 1 2  4
5  4 6 3 
8      73
  6  84  
 1 29    

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.

The solution

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.


Other pages

(c) John Whitehouse 2013 - 2020