Graphite sudoku

The maths of sudoku

You never add anything up in a sudoku, yet the puzzle is full of mathematics. Mathematicians have counted every possible grid, proved the smallest number of clues a puzzle can have, and linked sudoku to ideas going back to Euler.

No arithmetic required

The digits in a sudoku are labels, not quantities. You could replace 1 to 9 with nine letters, colours or shapes and the puzzle would work exactly the same. Solving is pure logic: if a digit can't go anywhere else, it goes here.

Some variants do use sums. Killer sudoku, for example, adds cages with totals. The classic puzzle never asks you to calculate.

How many completed grids?

In 2005 Bertram Felgenhauer and Frazer Jarvis counted every valid completed sudoku grid. The answer is 6,670,903,752,021,072,936,960, about 6.67 × 10²¹. They didn't list the grids one by one. Instead they worked out the possible fillings of the top band of three boxes, grouped the ones that behave alike, and had a computer count how many ways each group could be completed. The figure has since been confirmed independently.

To put it in perspective: if you looked at one grid per second, seeing them all would take about 15,000 times the age of the universe.

Essentially different grids

Many of those grids are really the same grid in disguise. You can relabel the digits, swap rows within a band, swap whole bands, do the same with columns and stacks, or reflect the grid across its diagonal, and every rule still holds. Grids that can be turned into each other this way count as one.

Counted like that, there are 5,472,730,538 essentially different sudoku grids, a figure found by Ed Russell and Frazer Jarvis in 2006. That is still more than five billion, and each grid can become many different puzzles, so nobody will run out.

The 17-clue minimum

For years, enthusiasts collected puzzles with 17 clues, eventually tens of thousands of them, but nobody ever found one with 16. In 2012 Gary McGuire, Bastian Tugemann and Gilles Civario settled the question. Their program checked every essentially different grid for a 16-clue puzzle with a unique solution and found none. The search used millions of hours of processor time, and the full paper was published in 2014.

The key idea was unavoidable sets: groups of cells whose digits could be rearranged to give another valid grid. Every puzzle with one solution needs at least one clue in each unavoidable set, so the search only had to test clue sets that hit all of them. The smallest unavoidable set is four cells in two rows, two columns and two boxes holding the same two digits crosswise, the pattern behind the unique rectangle.

It works the other way too: even 77 clues are not always enough. If the four empty cells form one of those rectangles, the puzzle has two solutions.

Sudoku and Latin squares

A Latin square of order n is an n×n grid with n symbols, each once in every row and column. Leonhard Euler studied them in the 18th century. Every completed sudoku is a Latin square of order 9 with one extra condition: each 3×3 box must also hold every digit.

That extra condition is very restrictive. There are about 5.5 × 10²⁷ Latin squares of order 9, so only around one in 830,000 of them is a valid sudoku grid.

Graphs and hard problems

Mathematicians also see sudoku as a colouring problem. Treat the 81 cells as points, join every pair of peers with a line, and colour the points with nine colours so that no line joins two points of the same colour. Each point has 20 neighbours, and there are 810 lines in all.

On bigger grids (16×16, 25×25 and up), solving sudoku in general is NP-complete, as Takayuki Yato and Takahiro Seta showed in 2003: no known method solves every large puzzle quickly. For an ordinary 9×9 grid that is no obstacle; a computer solves one in a few milliseconds. For a person, the interest lies in the logic, and in how hard its hardest step is: see difficulty levels.

Questions

How many possible sudoku grids are there?

6,670,903,752,021,072,936,960 completed grids, counted by Bertram Felgenhauer and Frazer Jarvis in 2005. Allowing for symmetries, 5,472,730,538 of them are essentially different.

Why is 17 the minimum number of clues?

Every puzzle with 16 or fewer clues has more than one solution. Gary McGuire, Bastian Tugemann and Gilles Civario proved it with an exhaustive computer search announced in 2012.

Is sudoku a maths puzzle?

It is a logic puzzle. The digits are only symbols and you never calculate with them, although there is interesting mathematics behind the grid.

Will we ever run out of sudoku puzzles?

No. There are billions of essentially different grids, and each grid can be turned into a huge number of different puzzles.