## Introduction

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.

• The problem.
• Interactive solver: An interactive Sudoku solver implemented in Javascipt. This allows you to solve the original 9 x 9 puzzle and a number of variants from 4 x 4 up to 16 x 16. You can also use it to create puzzles by adding digits incrementally until you find a solution.
• Variants: Explains how the the original 9 x 9 version can be extended to other sizes.
• Create Sodukos: This page uses Javascript to create puzzles for you to solve. It can create the classic 9 x 9 puzzle and a number of the variants.
• How to solve them: A walk-through and Python script. The Javascript used in the interactive version was developed from scratch so it is very different from the Python version, though is does use the same basic ideas.
• Some examples for you to solve: Some examples puzzles of varying sizes that you can try to solve.
• Some more examples: This page contains some 3x3 examples, but with the added twist that the two main diagonals must also contain the numbers 1 to 9.
• Python source code: Python scripts to download. You can download the javascript used on the interactive page from there.

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.
 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.

### 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.

 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

## Other pages

(c) John Whitehouse 2013 - 2020