Abakcus
← All articles
  • Combinatorics
  • Algorithms
  • Graph theory

The Mathematics of Sudoku: How Many Grids, Why 17 Clues

How many different Sudokus there are, why no puzzle can get below 17 clues, how a computer solves one, how any puzzle can be solved with pencil and paper, and how an 81-cell grid turns into a graph with 810 edges, told by counting, proving and solving step by step.

The 81 cells of a Sudoku grid drawn as points, the selected cell joined to its neighbours

Row 5, column 5. 8 neighbours in the same row, 8 in the same column and 4 more in the same box but in another row and column, 20 edges in all.

Each point is a cell. Tap a point and every cell that cannot hold the same digit is joined to it. Row neighbours arc upward, column neighbours arc to the left, and straight lines mark cells that share only the box.
6.67 × 1021filled 9×9 grids, counted by Felgenhauer and Jarvis
5,472,730,538essentially different grids, once symmetry is taken out
17clues, the proven minimum for a unique solution (2012)
810edges in the Sudoku graph, 20 at every cell

The rule fits in one sentence. In a 9×9 grid, every row, every column and every 3×3 box marked by thick lines must contain each of the digits 1 to 9 exactly once. Behind a rule that looks so innocent in the puzzle corner of a newspaper, combinatorics, algorithms, computational complexity and graph theory sit tangled together, and in this article I want to untie those knots one at a time, without hurrying.

I am not going to explain how to finish the puzzle faster than the person next to you, although I will not get through without stopping at a few powerful techniques along the way, and I will prove why they work. What I am really curious about is how many filled Sudoku grids exist, how many digits must be given for a puzzle to have a single solution, how a computer solves a Sudoku, and whether someone sitting with pencil and paper can reach the same certainty. Then there is the question of which mathematical object Sudoku really is in disguise, and I think the most beautiful answer is hidden there.

I have kept this article long, because most of these topics are either brushed off in a paragraph online or reduced to their final result. Here, for the reader who wants to see where the results come from, I have written out the calculation behind every number, the proof of every theorem and how every algorithm works its way through an actual puzzle step by step. Most of the diagrams are there so you can check with your own eyes what I say in the text.

I will use this puzzle several times in the article. By newspaper standards it is easy, and it falls from start to finish to the simplest techniques I describe shortly. Its solution sits beside it, folded away, so if you want to try it yourself, work on the puzzle first.

The opening puzzle

Its solution

Left, a puzzle I will come back to several times, 39 digits given and 42 cells empty. Right, its solution: printed digits are the given clues, handwritten digits are the ones I filled in.

Chapter 1 of 12

The rule, a short history and my notation

Euler's thirty-six officers, Howard Garns's Number Place, and the c(row, column) notation used from here to the end.

The mathematical family of Sudoku is much older than the puzzle itself. An n×n grid that obeys only the row and column rule, with no box condition, is called a Latin square, and Leonhard Euler studied them systematically in a long paper published in 1782. The question Euler pursued there was whether thirty-six officers, from six different regiments and of six different ranks, could be arranged in a 6×6 square so that every row and every column held exactly one officer of each regiment and each rank. That amounts to finding two orthogonal Latin squares at once. Euler guessed that no such arrangement exists and he was right. For 6×6 the answer was proved negative in 1900 when Gaston Tarry went through every case one by one. The more ambitious version in which Euler extended this guess to other orders was refuted in 1959.

Latin squares took a long time to reach the newspapers. In the 1890s some French newspapers ran number squares, but the form we know today, a 9×9 grid with the box rule and a few digits given in advance, appears in the United States in 1979. Puzzles prepared by Howard Garns, a retired architect from Indiana, were printed in Dell's pencil puzzle magazine under the name "Number Place". In 1984 the Japanese publisher Nikoli discovered the puzzle and gave it a long name meaning roughly "the digits must remain single", which Nikoli's founder Maki Kaji shortened, and that is how the name Sudoku was born. Its spread around the world began when Wayne Gould, a retired judge from New Zealand, wrote a program that generated the puzzles by computer. The Times printed its first Sudoku on 12 November 2004, and within a few months the puzzle had settled onto the back pages of nearly every newspaper.

  1. 1736Euler's paper on the bridges of Königsberg, usually taken as the start of graph theory.
  2. 1782Euler's long paper on Latin squares and the thirty-six officers.
  3. 1900Gaston Tarry checks every case: no 6×6 pair of orthogonal Latin squares exists.
  4. 1912George Birkhoff proves that counting colourings always gives a polynomial.
  5. 1959Euler's wider conjecture about orthogonal Latin squares is refuted.
  6. 1979Howard Garns's “Number Place” appears in Dell's pencil puzzle magazine.
  7. 1984Nikoli brings the puzzle to Japan; Maki Kaji shortens its name to Sudoku.
  8. 2000Donald Knuth publishes Algorithm X and dancing links.
  9. 2003Yato and Seta show that general n²×n² Sudoku is NP-complete.
  10. 200412 November: The Times prints its first Sudoku, after Wayne Gould's puzzle-making program.
  11. 2005Felgenhauer and Jarvis count 6,670,903,752,021,072,936,960 filled grids.
  12. 2006Russell and Jarvis: 5,472,730,538 essentially different grids.
  13. 2007Herzberg and Murty's chromatic polynomials; Thomas Snyder wins in Prague on a two-solution final.
  14. 2009J. F. Crook's pencil-and-paper algorithm in the Notices of the AMS.
  15. 2012McGuire, Tugemann and Civario: there is no 16-clue Sudoku.
From Euler's officers to the 16-clue proof, the dates this article passes through.

Seen from mathematics, Sudoku is a Latin square with one more condition added. I will show with numbers in the counting section how much that single extra condition changes, but first I want to fix the language I will use, because it will not change until the end of the article.

I number rows from top to bottom 1 to 9 and columns from left to right 1 to 9. I write a cell in the notation of J. F. Crook, who published a pencil-and-paper algorithm in 2009, as c(row, column). So c(6,7) is the cell where the sixth row meets the seventh column. Like Crook, I number the boxes in typewriter order, starting at the top left and going left to right and top to bottom from 1 to 9, so the middle box is box 5.

Box numbers

123456789
123456789

Cell c(6,7)

123456789
123456789
Left, the numbering Crook uses, boxes running from 1 to 9 in typewriter order. Right, c(6,7), the cell where row 6 meets column 7.

A cell must obey three units, its row, its column and its box. I will call rows, columns and boxes together units, and I note now that a grid has 27 units. Two larger structures will be useful in the counting section. Three stacked rows, that is rows 1-2-3, 4-5-6 or 7-8-9, I call a band, and three adjacent columns a stack. Each band consists of three boxes, and so does each stack.

Row 5

Column 5

Box 5

Band 1

Stack 1

The three units a cell has to obey, and two larger structures that matter in the counting section. Three stacked rows make a band, three adjacent columns make a stack.

Finally, two words need to be kept apart. A filled grid, all 81 cells filled in accordance with the rule, is a solution or completed Sudoku. A puzzle is a grid with digits written in some cells and the rest empty, and I call those digits clues. The question "how many Sudokus are there" counts filled grids, while "how few clues" is about puzzles. Not mixing up these two questions will make several subtle points later easier to see.

Chapter 2 of 12

Warm-up, 4×4 and 6×6 Sudoku

Counting Shidoku by hand: 288 grids, and why the count is a sum rather than a product.

Counting the small version by hand before moving to the 9×9 grid shows from the start why the big calculation is hard. 4×4 Sudoku, which some books call Shidoku, has four 2×2 boxes and digits running from 1 to 4. The rule is the same, every row, column and box contains 1, 2, 3, 4 once each.

I can write the first row however I like, since no rule has come into play yet, and there are 4! = 24 options there. Noticing a symmetry among these 24 options makes my job easier. Whether the first row is 2 4 1 3 or 1 2 3 4, I can pass from one to the other by renaming the digits. If I rename 2 as 1, 4 as 2, 1 as 3 and 3 as 4, the row 2 4 1 3 becomes 1 2 3 4, and this renaming carries every valid filling of the rest of the grid to another valid filling. So it is enough to count the grids whose first row is 1 2 3 4 and multiply the result by 24.

When the first row is 1 2 3 4, the first two cells of the second row lie in the same box and cannot take 1 and 2, so they are forced to be {3, 4}. The last two cells, for the same reason, are {1, 2}. Since each box has two orderings, the second row can be written in four ways.

Second row 3 4 1 2

Second row 3 4 2 1

Second row 4 3 1 2

Second row 4 3 2 1

With first row 1 2 3 4, the four possible second rows.

Things get interesting with the bottom two rows, and the whole difficulty of the big calculation appears here in miniature. When filling the third and fourth rows, each column has two digits unused in its top half, and these two digits must settle into the two cells below in some order. The bottom boxes also each need four different digits. When the second row is 3 4 1 2, the top half of the first column holds {1, 3} and the top half of the third column holds {3, 1}. These two columns have the same missing digits, {2, 4} in both. The same holds for the second and fourth columns, both missing {1, 3}. Because the columns pair up two by two in this way, four different completions of the bottom half appear.

When the second row is 3 4 2 1, however, the top halves of the columns are {1, 3}, {2, 4}, {3, 2} and {4, 1}, and all four missing pairs are different. This time there is no pairing between columns and the options lock into one another. When I write a digit in one cell, the choice forces another cell through the column, that cell forces another through the box, and at the end of the chain only two completions remain. The same reasoning applies to 4 3 1 2 and 4 3 2 1, and you can see every completion one by one in the diagram below.

Second row 3 4 1 2, 4 completions

Second row 3 4 2 1, 2 completions

Second row 4 3 1 2, 2 completions

Second row 4 3 2 1, 4 completions

Every 4×4 Sudoku whose first row is 1 2 3 4. There are twelve. Handwritten digits show the bottom half.

Altogether there are 4 + 2 + 2 + 4 = 12 completions, and the number of filled 4×4 Sudokus is 24 × 12 = 288. I also confirmed this number by having a computer check every possibility, and the result does not change.

This small calculation teaches two lessons of the big one in advance. First, the count cannot be made by multiplying options cell by cell. The sum 4 + 2 + 2 + 4 is not a product, and the reason is that how many options remain in a cell depends not just on how many digits were written in earlier cells but on exactly which digits they were. With second row 3 4 1 2 the bottom half has four options, with 3 4 2 1 it has two, yet in both cases the same digits were written in the second row. That is exactly why there is no tidy product formula for 9×9 either.

The second lesson concerns symmetries. Renaming the digits, swapping two rows within a band, swapping two bands, doing the same with columns and stacks, or reflecting the grid in the diagonal from top left to bottom right all carry a valid Sudoku to another valid Sudoku. If I count grids that can be transformed into one another this way as the same, the 288 grids turn out to come from just two different structures. Their numbers of copies are not equal either, one has 96 copies and the other 192. Unequal copy counts show that the first structure maps back onto itself under some transformations, that is, it is more symmetric. I will meet the same phenomenon again when counting "essentially different" 9×9 Sudokus.

Structure with 96 copies

Structure with 192 copies

Each of the 288 4×4 Sudokus can be carried by symmetries onto one of these two grids. The left one has 96 copies, the right one 192.

One step up, 6×6 gives a feel for the rate of growth. In 6×6 Sudoku, which is also common in newspapers, the boxes are not squares but rectangles of 2 rows and 3 columns. Crook calls these irregular Sudokus in his paper and lists the regular ones with box side m in a table. For m = 2 you get the 4×4 grid with 16 cells, for m = 3 the 9×9 grid with 81 cells, for m = 4 the 16×16 grid with 256 cells, for m = 5 the 25×25 grid with 625 cells and for m = 6 the 36×36 grid with 1,296 cells. When I had a computer count the filled 6×6 Sudokus, I got 28,200,960. Going from 4×4 to 6×6, the number of cells rises from 16 to 36 and the number of grids grows about a hundred thousand times. It is not hard to guess where this number will go at 9×9.

GridBoxCellsNumber of filled grids
4×42×216288
6×62×33628,200,960
9×93×3816,670,903,752,021,072,936,960
16×164×4256not known exactly

Chapter 3 of 12

How many Sudokus are there?

Four upper bounds, each tighter than the last, and the one thing none of them can see.

The question is simple. In how many different ways can I fill an empty 9×9 grid according to the rule? Rather than giving the answer straight away, I want to start with estimates that get steadily tighter, because seeing where and why each estimate goes wrong is the best way to understand why the true number, when it comes, is so hard to find.

Without any rule

The first crude estimate looks at no rule at all. I imagine filling the grid starting at the top left corner, row by row, left to right. I can write any of 9 digits in the first cell. The second cell also has at most 9 options, so there are at most 9 × 9 = 81 ways to fill the first two cells. The third cell multiplies this by 9 again, giving at most 9 × 9 × 9 ways for the first three cells. Carrying the same reasoning to the end of the 81 cells, I find that a filled grid can be written in at most

981 ≈ 1.97 × 1077

different ways. That is roughly a thousandth of the 1080 usually quoted for the number of atoms in the observable universe. Mathematicians call an estimate like this an upper bound. It does not say what the true number is, it only guarantees that the true number cannot be larger. The true number could be much smaller, and as I will show shortly, it is in fact much smaller.

Adding the row rule

Now I bring in a single rule, each row contains each digit at most once. Filling a row from left to right, the first cell has 9 options, the second has at most 8 because the digit in the first cell can no longer be used, the third 7, and the last cell just 1. So a row can be written in at most 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 9! = 362,880 ways. Even if the nine rows were filled independently, the total could not exceed this, and the new upper bound is the following.

(9!)9 = 362,8809 ≈ 1.09 × 1050

One rule brought a drop of 27 digits. It is useful for later steps to show this as a table that writes in each cell the most options that cell can have. Multiplying the 81 numbers in the table gives the upper bound.

The row-rule table. Each row's first cell has 9 options, its last cell 1. The product of the 81 numbers is (9!)9.

Why such a big improvement? Because in the first estimate I counted 9 options even for the last cell. But once the first eight cells of a row are filled, only one digit can go into the ninth. The number of ways to fill the first eight cells of a row is the same as the number of ways to fill the whole row. The crude estimate does not see this simple fact and kept multiplying by 9 at every cell.

Twelve cells that slip through

The row table still misses something. When filling the grid row by row, there are cells besides the end of each row that have only one option left. The ninth, that is the last filled, cell of a box is condemned to a single digit, since the other eight cells of the box are full. The last cell of box 1 is c(3,3), of box 2 c(3,6), of box 4 c(6,3), of box 5 c(6,6). The last cells of boxes 3, 6 and 9 are already at the end of a row, so their table value is 1. Likewise the last cell of a column has a single option, since the eight cells above it are full. The last cells of the columns sit in the ninth row, and apart from the row's own last cell c(9,9) there are eight of them. The last cells of boxes 7 and 8, c(9,3) and c(9,6), are among those eight.

The twelve red cells actually have a single option. Four are the last cell of their box, eight sit in the bottom row as the last cell of their column. Their table values are 7, 4, 7, 4 and 9, 8, 7, 6, 5, 4, 3, 2.

In these twelve cells the table counts 7, 4, 7, 4, 9, 8, 7, 6, 5, 4, 3, 2 options, whereas in reality each has one. So the previous upper bound overcounts by a factor of at least 7 × 4 × 7 × 4 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 = 9 × 8 × 73 × 6 × 5 × 43 × 3 × 2, and the new upper bound is

(9!)9 / (9 × 8 × 73 × 6 × 5 × 43 × 3 × 2) ≈ 3.8 × 1041

Another nine digits have dropped. But this method has a limit, since I only caught cells with a single option. Better is to take all three rules into account separately for every cell.

Three tables and their minimum

Next to the row table I place two more. In the column table I write in each cell the most options that cell has according to the column rule. Since I fill the grid from top to bottom, cells in the first row have 9 options, those in the second row 8 because one cell of their column is already filled, and those in the last row 1. In the box table each box repeats the sequence 9, 8, 7, 6, 5, 4, 3, 2, 1 internally, because the nine cells of a box are also filled row by row.

Row rule

Column rule

Box rule

The same grid through the eyes of three different rules. In the column table each row is constant, because however many cells above are filled, that many digits have been used up in the column. The box table repeats itself in every 3×3 box.

Whatever the true number of options in a cell is, it cannot exceed any of the three values. The row rule says at most so many, the column rule says at most so many, the box rule says at most so many, and the true value must satisfy all three at once. So taking the smallest of the three values for each cell is legitimate. The fourth table shows these minima, and the product of its 81 numbers becomes the new upper bound. In the selector below you can see the four tables and the product of each.

9
8
7
6
5
4
3
2
1
6
5
4
6
5
4
3
2
1
3
2
1
3
2
1
3
2
1
6
6
6
6
5
4
3
2
1
5
5
4
5
5
4
3
2
1
3
2
1
3
2
1
3
2
1
3
3
3
3
3
3
3
2
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1

Smallest of the three ceilings. Product of the 81 numbers ≈ 1.53 × 1031, about 2.3 billion times the true number of Sudokus.

Each number shows the most digits that could go in that cell when the grid is filled row by row. Red marks the cells where, in the minimum table, the value comes from one of the other two rules.
The cell-by-cell minimum of the three tables. Red values mark cells where a tighter ceiling than the row rule applies. The product is 15,284,122,844,890,207,459,737,600,000,000, about 1.53 × 1031.

The product of the 81 numbers is about 1.53 × 1031. I am 46 digits below where I started, about a 1046th of 981. But the true number is still about 2.3 billion times smaller than this, and a single example is enough to see where the gap comes from.

What the table cannot see

Suppose I filled the first row as 3 1 5 7 6 2 9 4 8 and the first five cells of the second row as 8 9 2 4 5, and it is now the turn of the sixth cell of the second row, c(2,6). According to the minimum table this cell has at most four options. In reality c(2,6) sees 8, 9, 2, 4 and 5 in its row, sees 7, 6, 2, 4, 5 in its box and sees 2 in its column. Only 1 and 3 remain. The table says four, the truth is two.

Filling row by row, I have reached the marked cell. The table allows 4 options here, in reality only 1 and 3 remain.

The difference comes from this. When computing the table value I applied each rule separately. The row rule said "five digits are used in this row, four remain", the box rule said "five digits are used in this box, four remain", and I took the smaller, four. But the digits used in the row and the digits used in the box are not the same digits, and their union excludes far more. The rules do not work one at a time but together, and together they are much stronger than any of them alone. It is impossible to fit this interaction into a table that writes a single number per cell, because the size of the interaction depends on exactly which digits were written in earlier cells. Remember how in 4×4 the second row being 3 4 1 2 or 3 4 2 1 changed the bottom half. The same phenomenon is at work here on a much larger scale.

Chapter 4 of 12

Counting by bands and the true number

Bands, 44 classes and a computer: 6,670,903,752,021,072,936,960 filled grids.

While the tables look at each cell separately, the road to the right answer runs through bigger pieces, especially bands. I can count by hand the number of ways to fill the first band, the top three rows, according to the rule, and this count is both pretty in itself and the first step of Felgenhauer and Jarvis's computer calculation.

Counting the first band

I use the relabelling symmetry here as well. Whatever the first row is, I can make it 1 2 3 4 5 6 7 8 9 by giving the digits new names. So if I fix the first row that way and count the other two rows, multiplying the result by 9! gives all bands.

With the first row fixed, what matters is which set of digits the second row puts into each box. The left box's first row holds {1, 2, 3}, the middle box's {4, 5, 6}, the right box's {7, 8, 9}. The second row of the middle box cannot take {4, 5, 6}, so it collects its three digits from {1, 2, 3} and {7, 8, 9}. There are four possibilities.

First, the second row of the middle box is entirely {7, 8, 9}. The whole second row must contain each digit from 1 to 9 once, the left box cannot take {1, 2, 3}, the middle box has taken {7, 8, 9}, and what remains is {4, 5, 6} for the left box and {1, 2, 3} for the right box. The third row is then determined. Second, the middle box's second row is entirely {1, 2, 3}, which likewise leads to a single arrangement. I call these the pure cases, and there are two of them.

In the third possibility, the middle box's second row takes one digit from {1, 2, 3} and two from {7, 8, 9}. There are 3 choices for which digit comes from {1, 2, 3} and 3 for which two come from {7, 8, 9}. Once that choice is made, the left box's second row cannot take {1, 2, 3}, so it must take the single digit left over from {7, 8, 9} and two digits from {4, 5, 6}, giving 3 more options. The right box's second row fills up with what is left. In total 3 × 3 × 3 = 27 arrangements. The fourth possibility mirrors the third, with the middle box taking two digits from {1, 2, 3} and one from {7, 8, 9}, and again gives 27 arrangements. I call these the mixed cases.

Pure case

Mixed case

The first row is fixed. In the left band the middle box's second row is made entirely of {7, 8, 9} and everything else falls into place. On the right the middle box's second row is {1, 8, 9}, which forces the one digit left over from {7, 8, 9}, the 7, into the left box.

Altogether there are 2 + 27 + 27 = 56 content arrangements. In each arrangement, each of the six box pieces of the second and third rows, six groups of three digits, can be written in 3! = 6 orders internally, and these orderings break no rule, because inside a band the column rule only asks that a digit not repeat in the three rows of a box, which the box rule already ensures. So with the first row fixed, the band can be completed in 56 × 66 = 2,612,736 ways, and together with the 9! ways of writing the first row, the number of filled bands is the following.

9! × 56 × 66 = 948,109,639,680

I also checked this number with a separate computer count.

The calculation of Felgenhauer and Jarvis

In 2005 Bertram Felgenhauer and Frazer Jarvis start exactly here. What they fix is the first box rather than the first row. By relabelling digits, the box 1 of every grid can be brought into the form 1 2 3 / 4 5 6 / 7 8 9, and that is why the total is exactly divisible by 9!. The problem reduces to finding how many ways the rest of the grid can be completed with box 1 fixed.

Felgenhauer and Jarvis's starting point. Relabelling digits brings the first box of any grid into this form, which is why the total is divisible by 9!.

With the first box fixed, boxes 2 and 3, the rest of the band, have 2,612,736 different fillings. The key idea of Felgenhauer and Jarvis is to notice that most of these fillings are equivalent as far as the number of completions of the bottom six rows is concerned. Swapping boxes 2 and 3, permuting the columns inside a box, swapping rows of the band and relabelling digits do not change the number of ways to complete the bottom six rows. Gathering the band fillings that transform into one another under these operations into one class, the 2,612,736 fillings come down to 44 classes. They take a single representative from each class, have the computer count how many ways the bottom six rows can be completed for it, multiply by the size of the class and add everything up. The resulting number is this.

6,670,903,752,021,072,936,960

About 6.67 × 1021. Its prime factorisation is 220 × 38 × 5 × 7 × 27,704,267,971, and the last factor is prime. Felgenhauer and Jarvis write the same number as 9! × 722 × 27 × 27,704,267,971.

This number is about a 2.3-billionth of the best upper bound I found by hand, 1.53 × 1031, and about a 3 × 1055th of the crudest bound, 981. I also picture a newspaper printing one Sudoku a day. If each puzzle's solution were a different filled grid, the paper could keep going for more than a billion times the current age of the universe. For anyone wondering whether a newspaper will run out of Sudokus, the answer is clear.

Within 0.2 percent by pencil and paper

It is possible to get surprisingly close to this number with pencil and paper, and I think this is the most elegant moment in the whole counting story. I imagine choosing each row independently as a random permutation of the nine digits. That gives (9!)9 grids, all of which already satisfy the row rule. I want to estimate what fraction of these also satisfy the column and box rules.

The probability that three random rows together form a valid band is the number of valid bands divided by the number of triples of random rows.

948,109,639,680 / (9!)3 ≈ 1.98 × 10−5

So about one in 50,000 random triples of rows forms a valid band. The grid has three horizontal bands and each must be valid. By symmetry I use the same probability for the three vertical stacks. A grid is a Sudoku only if all six structures are valid. If I assume these six conditions are independent, which they are not, since the same cells belong to both a band and a stack, my estimate becomes the following.

(9!)9 × (1.98 × 10−5)6 ≈ 6.657 × 1021

99.79 percent of the true number. The assumption is wrong, the result is nearly right.

As far as I know there is no rigorous explanation for why this estimate works so well. The band and stack conditions are dependent, but the dependence works both ways, sometimes raising the probability and sometimes lowering it, and in the end the effects seem to largely cancel. It is an observation, not a proven result.

Comparison with Latin squares

One way to see how powerful the box rule is, is to leave it out. The number of 9×9 grids obeying only the row and column rules, the Latin squares of order nine, is this.

5,524,751,496,156,892,842,531,225,600 ≈ 5.52 × 1027

Every Sudoku is a Latin square but not the other way round. The ratio is 6.67 × 1021 / 5.52 × 1027 ≈ 1.2 × 10−6, so roughly one Latin square in 830,000 is a Sudoku. The box rule is no innocent decoration on top of the row and column rules, it cuts the number by six digits.

  1. No rule at all, 9⁸¹1.97 × 1077
  2. Row rule, (9!)⁹1.09 × 1050
  3. Twelve forced cells3.8 × 1041
  4. Smallest of the three tables1.53 × 1031
  5. Latin squares, no box rule5.52 × 1027
  6. Pencil-and-paper estimate6.657 × 1021
  7. The true count, Felgenhauer and Jarvis6.671 × 1021
  8. Essentially different, Russell and Jarvis5.47 × 109
Every count in the last two chapters on one logarithmic scale. Each bar is as long as the number has digits. The pencil-and-paper estimate and the true count are indistinguishable at this scale, which is the point.

How many truly different Sudokus are there?

Most of the 6.67 × 1021 grids can be regarded as copies of one another. Every transformation I saw for 4×4 also works for 9×9, and here their numbers are much larger.

There are 9! = 362,880 ways to relabel the digits. I can order the three bands in 3! = 6 ways. I can order the three rows inside each band in 3! ways too, which for three bands gives (3!)3 = 216. The same operations on stacks and columns give 6 and 216 options. Finally there is reflecting the grid in the diagonal, reflect or not, 2 options. The number of transformations other than relabelling is

6 × 216 × 6 × 216 × 2 = 68 × 2 = 3,359,232

and together with relabelling the total is 3,359,232 × 362,880 = 1,218,998,108,160 transformations. Rotating the grid by 90 degrees seems missing from this list but is actually there, since a rotation is a reflection combined with reversing the order of the rows.

Original

Bands 1 and 2 swapped

Rows 1 and 2 swapped

Reflected in the diagonal

1↔2, 3↔4, 5↔6, 7↔8

Four copies of the same grid. Each is a valid Sudoku and all carry the same structure.

If every grid had 1,218,998,108,160 distinct copies under all transformations, dividing the total by this number would give the number of essentially different grids. I do the division.

6,670,903,752,021,072,936,960 / 1,218,998,108,160 = 5,472,447,994.27…

That the result is not a whole number is information in itself. The division could only come out clean if every grid produced completely distinct copies under all transformations. A fractional result proves, without showing a single example, that some grids map back onto themselves under some transformations, that is, symmetric Sudokus exist. Such a grid has fewer distinct copies, and plain division undercounts them. In 4×4 I saw two structures with 96 and 192 copies, and the same thing happens here in a far more complicated way.

The correct count uses a tool from group theory called Burnside's lemma. The lemma says the number of distinct structures equals the average, over all transformations, of the number of grids each transformation leaves unchanged. Most transformations leave no grid unchanged, some fix a small number of grids, and the calculation rests on counting those one by one. In 2006 Ed Russell and Frazer Jarvis do this calculation and find the number of essentially different filled Sudokus to be this.

5,472,730,538

About 282,000 more than plain division. Roughly five and a half billion structures. This number will come back shortly in the 17-clue story, because the computation proving there is no 16-clue puzzle examines exactly these five and a half billion grids one by one.

Chapter 5 of 12

How many clues does a unique solution need?

Deadly rectangles, unavoidable sets and the 7.1-million-core-hour proof that 16 clues never suffice.

Imagine you are working on a puzzle a friend made by hand. Let it be something like the one below.

Puzzle

One solution

Another solution

The fourteen-clue puzzle. Grey cells mark where the two solutions differ. Since even 16 clues are never enough, 14 clues cannot force a unique solution.

After a while two questions start to nag at you. Does this puzzle have a solution, and if so, is it unique? Both sound simple, but in general they are very hard to answer without a computer. This puzzle has a solution, but not a unique one. I have put two of its solutions side by side above, and if you look closely the two differ in only four cells. I will show shortly why those four cells form an exact rectangle. A unique solution with fourteen clues is impossible anyway, but why that is so is the subject of a 2012 proof I describe at the end of this section.

First I want to separate the two questions. The existence question asks "is there at least one solution", the uniqueness question "is there at most one". Nearly all puzzles printed in newspapers and books are made to have a unique solution, and most solvers regard this as a mark of quality. But it is not always so. Crook tells in his paper how the final puzzle of the 2007 World Sudoku Championship had exactly two solutions. I will return to that story later.

Three empty cells always give a unique solution

I approach uniqueness from the extreme end. If only three empty cells remain in the grid, the other 78 cells are filled according to the rule, and I know the puzzle has at least one solution, then the solution is certainly unique. To see this, it is enough to show that at least one of the three empty cells is alone in its row or alone in its column.

Three empty cells. c(1,1) is alone in both its row and its column, so its value is immediately determined.

I assume the opposite, that none of the three cells A, B and C is alone in its row or its column. A shares its row with someone, say B. A must also share its column with someone, and that cannot be B, since two cells in the same row and the same column would be the same cell. So A and C are in the same column. B also shares its column with someone, and since it is in the same row as A, that someone cannot be A, so it is C. Then C is in the same column as both A and B, so A and B are in the same column too, and A and B lie in the same row and the same column. That is the contradiction.

The value of the cell that is alone in its row or column is determined automatically as the one digit missing from that row or column. Since I know the puzzle has a solution, I am also sure that digit fits the cell. Once I write it, the situation for the two remaining empty cells is even easier. The two cells are either in the same row, in the same column, or in neither. Whichever it is, each is at least alone in its row or its column, because if they share a row they are in different columns and alone in their columns. So each is condemned to a single digit and the solution is unique.

Four empty cells are not enough

With four empty cells the same guarantee disappears, and seeing why is the key to a structure that will come up again in the rest of the article. The grid below appears as an exercise in the Cornell notes. When everything that can be filled with easy techniques is filled, four empty cells remain, and those four cells can be filled in two different ways.

The four empty cells form a rectangle spread over two rows, two columns and two boxes. Swap 1 and 2 at its corners and every row, column and box still obeys the rule, so there are two solutions.

The four cells are c(1,3), c(1,4), c(3,3) and c(3,4). They form a rectangle spread over two rows, two columns and two boxes, boxes 1 and 2. Each row is missing {1, 2}, each column is missing {1, 2}, and each box is missing {1, 2}. When I write 1 in one corner, the opposite corner also gets 1 and the other two corners get 2, and both diagonal arrangements obey every rule.

The rectangle splitting into exactly two boxes is essential here. If the four corners fell into four different boxes, that is if the rectangle spanned two bands and two stacks, each box would have only one empty cell and the box rule would force each cell to a single digit. If the four corners were in a single box, the box would demand four different digits even though the corners share rows and columns, and the diagonal arrangement would not work. The rectangle must cross two rows and two columns, its corners must fall two by two into two boxes, and the digits at the corners must match diagonally. Some puzzle books call this pattern a deadly rectangle, because if such a structure exists in a puzzle's solution and the puzzle gives no clue in it, the puzzle is doomed to two solutions.

Unavoidable sets

This observation generalises. I consider a group of cells in a filled Sudoku. If the digits in those cells can be rearranged, the digits themselves staying the same but their positions changing, so that the grid is still valid, that group of cells is called an unavoidable set. The name comes from its consequence. A puzzle with a unique solution must give at least one cell of every unavoidable set of its solution as a clue. Otherwise the digits in that set swap places without touching any clue and a second solution is born. The puzzle setter cannot avoid these sets and must leave at least one clue in each.

The four-cell rectangle above is the smallest kind of unavoidable set. Nothing smaller is possible, and the three-empty-cell proof says exactly this. If every solvable puzzle with three or fewer empty cells has a unique solution, there is no unavoidable set of three or fewer cells. Not every grid has a four-cell unavoidable set, but larger ones always exist, and a typical grid has hundreds. That is also why the two solutions of your friend's fourteen-clue puzzle differ in an exact rectangle. That grid has a four-cell unavoidable set and the puzzle gave no clue in it.

The eight-digit rule

Another short and pleasant result follows from the same idea. Among the clues of a uniquely solvable puzzle, at least 8 of the 9 digits must appear. If two digits, for example 5 and 7, never appear among the clues, then in any solution I can turn every 5 into 7 and every 7 into 5 without touching the clues, and the new grid also obeys the rules, because every unit still has one 5 and one 7. So I get a second solution. In the language of unavoidable sets, the 18 cells holding the 5s and 7s in the solution form an unavoidable set and the puzzle put no clue in any of them. Agnes Herzberg and Ram Murty prove this result in 2007 in the language of graphs, and I will return to that language at the end of the article.

It is worth noticing that the rule says eight, not nine. The ninth digit not appearing among the clues does not by itself spoil uniqueness, because a swap needs two missing digits and a single missing digit has no partner to trade places with. Eight digits are of course not enough for uniqueness, only necessary. Mathematics calls such conditions necessary rather than sufficient.

The proof of 17

For years the number of clues in uniquely solvable puzzles did not drop below 17. Gordon Royle, a mathematician at the University of Western Australia, collected 17-clue puzzles sent in from around the world from 2005 onward, and the collection eventually reached about 49,000 different puzzles. One of them is below. Not a single 16-clue puzzle ever entered the collection.

17 clues

Its unique solution

One of the 17-clue puzzles in Gordon Royle's collection. Notice that all nine digits appear, fewer than 8 would not do.

Still, finding nothing does not prove there is nothing. Perhaps 16-clue puzzles existed and were just very rare. So for years the question stayed an open conjecture. Many sources, the Cornell notes included, still say "the minimum number of clues is probably 17", but that sentence is now out of date.

A quick calculation shows why brute-force search does not work. If I took one filled grid and wanted to test every subset of 16 of its cells to see whether it formed a uniquely solvable puzzle, I would have to try the C(81, 16) ≈ 3.4 × 1016 ways of choosing 16 cells out of 81 one by one. And this has to be done for each of the 5.47 billion essentially different grids. Even if I could check a single puzzle for uniqueness in a millisecond, the total time would far exceed the age of the universe.

In early January 2012 Gary McGuire, Bastian Tugemann and Gilles Civario publish the work that settles the question, and the paper appears in Experimental Mathematics in 2014. The skeleton of the method is built from the unavoidable sets above. They take each of the 5,472,730,538 essentially different grids in turn and first look for unavoidable sets in each. In a typical grid they find about 360, and they report that this takes about 30 seconds per grid. Then they ask the following question. Is there a selection of 16 cells that touches every one of these sets in at least one cell?

In computer science this is called the hitting set problem. A family of sets is given and a small selection is sought that "hits" every set in the family with at least one element. If a uniquely solvable 16-clue puzzle existed, its 16 clues would have to hit every unavoidable set of the grid. So they first find the 16-cell selections that hit all unavoidable sets, and the unavoidable sets narrow the search enormously from the start, then they check only these candidates for uniqueness. In no grid does a 16-cell selection pass the hitting set test and also give a unique solution.

The whole computation takes about 7.1 million core hours on the Stokes machine at the Irish Centre for High-End Computing. With a single processor core that would be about 800 years. The paper also has a nice example showing, using more complex structures where several unavoidable sets in the same grid combine, that some grids can be proven without a computer to need at least 18 clues.

So 17 stops being a conjecture and becomes a theorem. 16 clues are never enough, and a unique solution with 17 clues is possible. That the 17 clues of the puzzle above contain all nine digits is no accident either, the eight-digit rule already requires at least eight of them.

The existence question

The existence question has a plainer answer. Whether a grid can be completed can always be decided, because there are finitely many ways to fill the grid and scanning them all systematically always gives a result. The problem is not whether the answer exists but how much effort it takes. The next section is exactly about how to organise that effort.

Chapter 6 of 12

How does a computer solve a Sudoku?

Backtracking, the tightest-cell rule, exact cover and NP-completeness.

The most basic requirement of an algorithm is that it stops. "Looking at the puzzle and trying things" is not an algorithm for that reason, a person might never finish, might repeat the same attempts again and again or might give up somewhere. A real algorithm for Sudoku must take a partly filled grid and, after a finite number of steps, stop either by finding a solution or by showing there is none. The simplest method that does this is the direct continuation of the "fill cell by cell" idea from the counting section.

The simple solving algorithm

The Cornell notes call this method the "simple solving algorithm". In computer science it is called backtracking. The steps are as follows.

  1. Number the empty cells in typewriter order, left to right and top to bottom.
  2. Make the first cell in the list the current cell.
  3. Write 1 in the current cell. If this creates a repeat in a row, column or box, try 2, then 3, and continue until you either find a digit that breaks no rule or try 9 and still meet a violation.
  4. If you found a digit that obeys the rule and this is the last cell in the list, the puzzle is solved. If it is not the last cell, make the next cell in the list the current cell and return to step 3.
  5. If every digit up to 9 is a violation and this is the first cell in the list, the puzzle has no solution. If it is not the first cell, empty this cell, go back to the previous cell in the list, continue trying there by increasing its digit by one and make the checks of step 3.

It is not hard to see the method is correct. As the algorithm fills cells in order, it tries digits from small to large for each cell, and when all digits are exhausted in one cell it moves on to the next digit of the previous cell. This means scanning the list of filled grids in lexicographic order, the order in which words are arranged in a dictionary, and during the scan it never continues a partial filling that breaks the rule. If a solution exists the scan must reach it, because every partial filling in front of it leads either to a solution or a dead end, and the dead ends are finite. If there is no solution the scan exhausts all possibilities and stops when the first cell goes past 9.

Changing the algorithm to find all solutions is easy too. When a suitable digit is written in the last cell, instead of stopping you record the solution, erase that digit and continue the search as if you had hit a dead end. When the scan ends all solutions are recorded. I found the second solutions of the two-solution examples above with this method. For someone making puzzles this change is very useful, because they can check whether a puzzle has a unique solution by seeing whether a second solution turns up.

It is also clear that this method is almost impossible to apply on paper. The number of digits to write and erase, as I will show shortly, runs into the hundreds of thousands. The MATLAB code Paul Meerkamp wrote in 2009 for a summer programme at Cornell solves the "fiendish" puzzle below in about five minutes, and Meerkamp writes that his code is about as fast as a human on most puzzles and much slower on some.

Puzzle, 25 clues

Solution

The puzzle rated "fiendish" on which Meerkamp tested the simple backtracking algorithm. His 2009 MATLAB code takes about five minutes on it.

Tightest cell first

A single small change shortens that time incredibly. Choose the next cell not in typewriter order but as the cell with the fewest options at that moment. A cell with one option is really a forced move, and making it immediately narrows the rest of the search without any branching. A cell with zero options tells me I am on the wrong path before I even enter that branch, and the algorithm backs up at once. Typewriter order only notices such a cell when its turn comes, and until then it branches pointlessly in all the cells in between.

Below you can run the two methods side by side on the same puzzles. Both step at the same speed, that is, in every frame each writes or erases the same number of digits. The difference comes entirely from which cell gets chosen.

Typewriter order

Fills empty cells left to right and tries digits 1 to 9.

Digits written 0

Tightest cell first

At each step picks the cell with the fewest options left and tries only those.

Digits written 0

The counters record digits written into a cell because they broke no rule. Both methods step at the same speed, so the whole difference comes from which cell gets chosen.

The numbers tell their own story.

PuzzleCluesTypewriter orderTightest cell first
The opening puzzle3918342
Mepham's "diabolical" puzzle2810,923257
Krazydad, first of the super-tough book2472,122116
Will Shortz's no. 30123547,2081,426

The numbers in the table are the total count of digits written into a cell because they broke no rule. In the opening puzzle the tightest-cell rule fills 42 empty cells with 42 digits, so it never backs up. This means there is a single-option cell at every step, and as I will show shortly, this puzzle is indeed solved by the single-candidate rule alone. In Shortz 301, by contrast, typewriter order writes and erases more than half a million digits while the tightest-cell rule finishes the job with 1,426.

I notice something else. A puzzle a human finds hard and a puzzle a program working in typewriter order finds hard are not the same thing. For typewriter order, difficulty depends on how late wrong choices in the first rows are discovered. A puzzle with an empty first row can be very expensive for typewriter order however full its lower rows are. A human never thinks in typewriter order anyway, the eye goes to the fullest unit, the tightest cell. The tightest-cell rule is, in a sense, human intuition taught to a computer.

The tightest-cell rule is, in a sense, human intuition taught to a computer.

Chapter 6, the race

The true shape of Sudoku, exact cover

Computer scientists look at Sudoku a little more abstractly, and this view shows both how fast solvers work and how Sudoku is related to other problems. I write every possible move as a triple "row r, column c, digit d". There are 9 × 9 × 9 = 729 such moves. Each move satisfies exactly four conditions.

  1. It fills cell c(r, c). There are 81 conditions of this kind, one for each cell.
  2. It puts digit d in row r. 81 conditions for 9 rows and 9 digits.
  3. It puts digit d in column c. Again 81 conditions.
  4. It puts digit d in the cell's box. Again 81 conditions.

There are 324 conditions in total. For example, the move "row 2, column 7, digit 9" fills cell c(2,7), puts 9 in row 2, puts 9 in column 7 and puts 9 in box 3. Solving a Sudoku means choosing 81 of the 729 moves so that each of the 324 conditions is met exactly once. No condition may be met twice, since that would mean two digits in one cell or the same digit twice in a unit, and no condition may be left open. The clues make part of this choice in advance.

This is a general problem called exact cover. Picture a 0-1 table with 729 rows and 324 columns. Each row is a move, each column a condition, and there is a 1 where a move meets a condition. Every row has exactly four 1s. What is wanted is to choose rows so that, laid on top of one another, they leave exactly one 1 in every column. Pentomino puzzles, some scheduling problems and the problem of placing queens on a chessboard fall into the same mould.

In a paper published in 2000, Donald Knuth describes a search method for such problems called Algorithm X, and a data-structure technique he calls "dancing links" for running it efficiently. Algorithm X at each step chooses, among unmet conditions, the one that can be met by the fewest moves, tries one of those moves, temporarily removes all conflicting moves from the table, and puts them all back if it hits a dead end. Dancing links does this removing and restoring almost for free. It is not hard to see that the tightest-cell rule is the Sudoku special case of choosing the condition with the fewest options first in exact cover. The difference is that Algorithm X looks not only at cell conditions but also at conditions like "where can 9 go in row 2", and so it automatically includes the technique humans call a "single place". A 9×9 Sudoku is solved this way in a small fraction of a second.

So is Sudoku an easy problem?

For 9×9, yes. But when I ask the question for general Sudoku the answer changes. Sudoku of size n²×n² with box side n, the family growing as 4×4, 9×9, 16×16, 25×25, was shown to be NP-complete in 2003 by Takayuki Yato and Takahiro Seta. What does that mean?

If I can quickly check a proposed solution to a problem, the problem is in the class NP. Sudoku is like that, checking the 27 units of a filled grid is a job that grows very slowly as the grid grows. Being NP-complete means every problem in NP can be quickly translated into this problem. If a method were found that solves general Sudoku quickly in every case, the same method would quickly solve every problem in NP, the decision version of the travelling salesman problem, the satisfiability of logical formulas, whether a timetable can be built and thousands more. That would mean answering the most famous open question in computer science, whether P equals NP. Most researchers think no such method exists.

Yato and Seta's actual result is a little subtler. They show that deciding whether a puzzle with a known solution has a second solution is also hard. This is a familiar trouble for puzzle setters, because checking that a puzzle has a unique solution is no easier than solving it.

That the 9×9 newspaper puzzle is solved quickly comes not from the nature of the problem but simply from its being small. 81 cells and 729 moves are no trouble for a computer even in the worst case. But if you announced you had written a program that quickly solves 100×100 Sudoku in every case, the mathematical world would hand you a million-dollar prize along with some very serious questions.

Chapter 7 of 12

Two basic methods for solving by hand

Single candidates and single places, and the opening puzzle solved in 42 steps.

Backtracking does not work on paper. Most newspaper puzzles, however, fall to two simple techniques, and I want to define them a little more carefully, because Crook's algorithm is built on top of both.

In the first method I look at cells. For each empty cell I check which digits are already present in its row, column and box and determine the rest, the candidates that could be written in that cell. If a cell has a single candidate left, I write that digit. The Cornell notes call this candidate-checking, and I will call it the single-candidate rule for short. Puzzle books also call the same thing a naked single.

In the second method I look at digits and units. Every unit must contain every digit exactly once. I take a row, column or box and look at how many cells in that unit the digit 1 could go into. If only one cell remains, the 1 goes there. Then I do the same for 2, then for 3, and I go through every unit. The Cornell notes call this place-finding, and I will call it the single-place rule. Books also call it a hidden single.

The two methods look like two faces of the same thing but they are not. The single-candidate rule looks at a cell and says "only 7 can go here". The single-place rule looks at a unit and says "7 can only go into this cell here", and it makes me write the 7 even if that cell has other candidates. They catch different situations, and a good solver uses them alternately. When one stalls the other may find a new digit, and that digit may set the first going again.

Knowing when these two methods are exhausted matters too. If since the last digit was written I have gone through every cell for a single candidate and every unit for a single place for every digit, and found nothing, I am sure these two methods cannot take me further. However long I look the result will not change, because the state of the puzzle has not changed.

The opening puzzle, step by step

The puzzle at the start of the article is a good example of how far these two methods can go. First I write the candidates of every empty cell. Crook calls this list of small digits the mark-up, and I will use that word from now on.

Full mark-up of the opening puzzle. Each empty cell carries, in small print, the digits not yet present in its row, column or box.

Looking at the mark-up, several cells with a single candidate stand out immediately. As I fill them, I delete the same digit from the mark-up of their neighbours, and new single candidates appear. After the first six steps the grid looks like this. Subscripts show the order in which digits were written, and struck-out small digits are the candidates eliminated in those steps.

After the first six steps. Subscripts show the order of entry, struck-out small digits are candidates eliminated along the way.

Right to the end of the puzzle, at every step at least one cell has a single candidate, and I never need the single-place rule. The table below holds all 42 steps. When building the table I scanned the grid in typewriter order at every step and filled the first cell with a single candidate, so a different order would lead to the same result.

StepCellDigitReason
1c(4,6)5Only 5 left in the mark-up.
2c(1,6)1Only 1 left in the mark-up.
3c(1,7)7Only 7 left in the mark-up.
4c(1,2)9Only 9 left in the mark-up.
5c(1,9)5Only 5 left in the mark-up.
6c(4,4)8Only 8 left in the mark-up.
7c(4,3)7Only 7 left in the mark-up.
8c(3,3)2Only 2 left in the mark-up.
9c(3,6)6Only 6 left in the mark-up.
10c(2,5)2Only 2 left in the mark-up.
11c(3,5)5Only 5 left in the mark-up.
12c(4,8)6Only 6 left in the mark-up.
13c(2,8)1Only 1 left in the mark-up.
14c(2,2)8Only 8 left in the mark-up.
15c(2,7)6Only 6 left in the mark-up.
16c(2,9)9Only 9 left in the mark-up.
17c(4,9)4Only 4 left in the mark-up.
18c(5,1)6Only 6 left in the mark-up.
19c(5,4)2Only 2 left in the mark-up.
20c(5,6)9Only 9 left in the mark-up.
21c(5,3)8Only 8 left in the mark-up.
22c(5,5)3Only 3 left in the mark-up.
23c(6,1)1Only 1 left in the mark-up.
24c(3,1)7Only 7 left in the mark-up.
25c(3,2)1Only 1 left in the mark-up.
26c(6,3)9Only 9 left in the mark-up.
27c(6,7)2Only 2 left in the mark-up.
28c(6,9)8Only 8 left in the mark-up.
29c(6,8)3Only 3 left in the mark-up.
30c(7,8)5Only 5 left in the mark-up.
31c(7,9)6Only 6 left in the mark-up.
32c(7,5)7Only 7 left in the mark-up.
33c(7,2)2Only 2 left in the mark-up.
34c(8,1)3Only 3 left in the mark-up.
35c(8,4)5Only 5 left in the mark-up.
36c(8,5)9Only 9 left in the mark-up.
37c(8,6)2Only 2 left in the mark-up.
38c(8,7)1Only 1 left in the mark-up.
39c(8,8)8Only 8 left in the mark-up.
40c(9,2)7Only 7 left in the mark-up.
41c(9,5)6Only 6 left in the mark-up.
42c(9,7)4Only 4 left in the mark-up.
The opening puzzle falls in 42 steps using only the single-candidate rule. Subscripts give the order.

Even in so easy a puzzle the power of the mark-up shows. It is also the reason the tightest-cell rule in the race finished this puzzle with 42 digits without a single backtrack. At every step there is a single-option cell and the tightest-cell rule picks it.

In hard puzzles, though, both methods stall at once. An exercise in the Cornell notes suggests the reader find a puzzle labelled "hard" and try to solve it with these two methods alone, and the purpose of the exercise is precisely to experience this stalling. In Shortz 301 the two methods together write only a few digits and then stop. In Mepham's puzzle they stop after ten digits. A stronger tool is needed.

Chapter 8 of 12

Crook's method and preemptive sets

Mark-up, the occupancy theorem, and why hidden sets are preemptive sets in disguise.

J. F. Crook, professor emeritus of computer science at Winthrop University, proposes in a 2009 paper in the Notices of the AMS a method that solves any Sudoku with pencil and paper. The paper opens with an interesting sentence. According to Crook, Sudoku is in fact a trivial puzzle, because an algorithm exists that solves it, a tree search based on backtracking. He asks why people bother with pencil and paper when anyone could punch the digits into a computer and wait for the solution, and takes his answer from Herzberg and Murty. The puzzle is hard enough to be a serious mental challenge, yet scanning rows and columns to find missing digits is easy enough to encourage the solver to persist. I also like a side story in the paper. Crook received his first Sudoku book as a present at Christmas 2005 and his second on his seventieth birthday in 2007, and he says so in the acknowledgements.

Crook's first example is the puzzle below with its mark-up. Crook himself says that marking up by hand is tedious and error-prone, and adds that he wrote a small Visual Basic program running in Excel for the job, since Excel's table structure is perfect for holding a Sudoku.

Puzzle

123456789
123456789

Mark-up

The first example puzzle in Crook's paper and its mark-up. Solving hard puzzles efficiently starts with writing these small digits.

Preemptive sets

Crook's method rests on a single concept. In puzzle books the same idea goes by different names, matching, partnership, naked pair, naked triple. Crook chooses the name preemptive set, which he finds more precise mathematically.

Definition

A preemptive set is a pair consisting of m digits chosen from 1 to 9 and m empty cells, such that no digit other than those m digits appears in the mark-up of those m cells. Here 2 ≤ m ≤ 9. Crook writes a preemptive set as {[n1, …, nm], [c(i1, j1), …, c(im, jm)]}.

The subtlety of the definition is that the cells need not carry all m digits. {[4, 7], [c(2,1), c(2,9)]} is a preemptive pair because both cells have mark-up {4, 7}. But in a triple such as {[1, 2, 6], [c(1,7), c(1,9), c(2,9)]} the mark-ups of the cells can be {1, 6}, {1, 2} and {2, 6}. No cell carries all three digits, but across the three cells only these three digits occur, and that is enough. When a preemptive set is found, how its m digits will be distributed among its m cells is not yet known, that distribution emerges as the puzzle progresses.

Definition

If all cells of a preemptive set lie in the same row, the same column or the same box, that unit is the range of the set. For m = 2 or 3 the cells may be both in the same row and the same box, or both in the same column and the same box, and then the set has two ranges.

Occupancy theorem

Let X be a preemptive set. The digits of X cannot be part of the solution in cells that lie in the range of X but do not belong to X. That is, those digits can be crossed out of the mark-ups of these cells.

The proof is nothing more than the pigeonhole principle. The m cells of X can take only the m digits of X. If one of the digits of X is written in a cell of the range outside X, that digit is used once in the range and can no longer enter the cells of X. Then m − 1 digits remain to be distributed over the m cells of X and one of the cells must stay empty. That contradicts the definition of a solution, which wants every cell filled. So the digits of X cannot be part of the solution anywhere in the range outside X.

The most common form of the occupancy theorem is the preemptive pair. If two cells in a row both have mark-up {4, 7}, then 4 and 7 are locked into these two cells. Even though I do not yet know which goes where, 4 and 7 cannot be in any other cell of that row, and I can cross them out. This crossing out sometimes leaves a single candidate in a cell, sometimes squeezes a digit into a single place in a unit, and sometimes reveals a new preemptive set. Crook's method uses this chain reaction systematically.

Hidden sets are really preemptive sets

Besides naked sets, puzzle books talk about hidden sets. A hidden pair is the situation where two digits in a unit occur only in the same two cells. The mark-up of those two cells may contain other digits too, but since these two digits cannot go anywhere else in the unit, they claim those cells and the other candidates can be crossed out. The second theorem in Crook's paper says hidden sets are really another face of preemptive sets. I want to write it with its proof, because it shows why what books present as two separate techniques are the same thing.

Let a unit have k empty cells. The unit is missing k digits, and these k cells, together with the k missing digits, form a preemptive set by default, in Crook's phrase. Because no digit not missing from the unit can appear in the mark-up of these cells. Now suppose I find a preemptive set of m cells inside this unit. Those m cells will share the m digits among themselves, and the remaining k − m cells must share the remaining k − m digits. So these k − m cells also form a preemptive set with the remaining k − m digits. Hence every preemptive set has a complement within the unit.

What books call a hidden set is a preemptive set whose complement is easier to spot by eye. Finding a hidden single in a box with four empty cells, that is, seeing that a digit can go to only one place in the box, is the same job as seeing that the remaining three cells form a preemptive triple. Crook states this as saying that whenever a preemptive set is found, its complement can always be seen too, and adds that the only exception is the singleton, since a one-cell set already means writing a digit.

Crook illustrates the idea in his paper with a three-box figure. In box 3, the mark-ups of cells c(1,7), c(1,9) and c(2,9) contain only 1, 2 and 6. This preemptive triple crosses 1, 2 and 6 out of the rest of the box. After the crossing out only 8 remains in c(1,8). Writing it also crosses 8 out of the mark-up of c(3,8), and the two empty cells left in the box, c(2,7) and c(3,8), form a preemptive pair with digits {3, 5}. The pair was hidden at first by the 6 and by the 2 and 8 in between, which is why it is a hidden pair. At the start the box was a default preemptive set of six cells and six digits. In the end it split into a three-cell triple and a two-cell pair, with a singleton in between. Crook's method consists of splitting every unit into ever smaller preemptive sets in this way.

The first half of the algorithm

The part of Crook's algorithm that needs no guessing can be summarised as follows.

  1. Find the forced digits. Crook suggests starting with the most frequent digit. You find a box missing that digit and see whether the digit can go into only one cell of that box. If so, you write it. When that digit makes no more progress you move on to the next most frequent.
  2. Mark up the puzzle.
  3. Search all rows, columns and boxes for preemptive sets. Whenever you find one, cross digits out of the mark-ups according to the occupancy theorem, write any singletons that appear, and keep searching.
  4. If the puzzle is solved, stop. If no unit can be split into smaller preemptive sets, move to the guessing stage.

In the next section I will show how this part solves Shortz 301 from start to finish, with every step.

Chapter 9 of 12

Shortz 301, step by step

A puzzle labelled “Beware! Very Challenging”, solved without a single guess.

Crook's example that needs no guessing is puzzle 301 from a book compiled by Will Shortz, the puzzle editor of the New York Times. The book prints it labelled "Beware! Very Challenging". It has 23 clues and is noticeably sparser than most newspaper puzzles.

123456789
123456789
Will Shortz's puzzle 301, 23 clues. The book labels it "Beware! Very Challenging".

First I try the two simple methods. Single candidates and single places together write only seven digits. In row 2 the only cells for 9 and for 1 are c(2,6) and c(2,3). These are the two digits Crook calls forced numbers in the paper. Next the only place for 7 in column 9 turns out to be c(5,9), only 5 remains in c(4,7), and in box 3 the digits 5, 8 and 3 fall into place in turn. Then everything stops. The initial mark-up is below.

Initial mark-up of Shortz 301. No cell has a single candidate, but a few digits have only one possible place in some row, column or box.

At this point Crook's method comes in. From here on, at every step I either find a preemptive set and cross digits out of mark-ups, or fill the single candidates and single places those crossings reveal. On the path I followed, six preemptive sets are enough. All are pairs, and I show each one below at the moment it was found.

Preemptive pair 1, {2, 8}, column 3

Preemptive pair 2, {3, 4}, row 8

Preemptive pair 3, {2, 6}, row 2

Preemptive pair 4, {2, 6}, column 9

Preemptive pair 5, {2, 6}, box 8

Preemptive pair 6, {4, 5}, row 9

The six preemptive sets used in solving Shortz 301, each at the moment it was found. Grey cells form the set, red-framed cells lost a candidate. Struck-out digits are candidates eliminated up to that point.

The first preemptive pair is in column 3, in cells c(3,3) and c(4,3). Both have mark-up {2, 8}, so 2 and 8 are crossed out of the rest of column 3. Exactly this pair appears in Crook's paper too, and Crook writes that it reveals a preemptive quadruple with digits {3, 4, 5, 9} in box 7. On my path the same crossing out turns c(8,3) and c(8,8) in row 8 into the pair {3, 4}. That pair is on Crook's list too. So are the {2, 6} pair in box 8 and the {4, 5} pair in row 9. In Crook's paper, once these five sets are found together, only 7 remains in the mark-up of c(8,7) in row 8, only 8 in c(8,1) and only 3 in c(9,4). In my table the same digits come in a slightly different order, because I use the first set I find at each step immediately.

The difference does not matter. Preemptive sets are determined by the state of the puzzle, not by the order in which I find them. Once a set has appeared, it does not vanish as other sets are found and other digits crossed out, it can only split into smaller pieces or fill up completely. That is why two solvers proceeding in different orders reach the same solution.

The table below lists all 58 digits and the six preemptive sets in the order they were found. Preemptive-set rows have a grey background, and step numbers are given only to written digits.

StepCellDigitReason
1c(2,6)9The only place for 9 in row 2.
2c(2,3)1The only place for 1 in column 3.
3c(5,9)7The only place for 7 in column 9.
4c(4,7)5Only 5 left in the mark-up.
5c(3,8)5The only place for 5 in column 8.
6c(1,8)8The only place for 8 in column 8.
7c(2,7)3The only place for 3 in box 3.
preemptive setIn column 3, cells c(3,3) and c(4,3) form a preemptive pair with digits {2, 8}. Removed 2 and 8 from c(5,3), 2 and 8 from c(8,3) and 2 from c(9,3).
8c(8,1)8The only place for 8 in row 8.
9c(8,7)7The only place for 7 in row 8.
10c(9,7)6The only place for 6 in box 9.
11c(1,7)1Only 1 left in the mark-up.
12c(5,7)4Only 4 left in the mark-up.
preemptive setIn row 8, cells c(8,3) and c(8,8) form a preemptive pair with digits {3, 4}. Removed 3 from c(8,4) and 3 and 4 from c(8,6).
13c(1,6)4The only place for 4 in column 6.
preemptive setIn row 2, cells c(2,5) and c(2,9) form a preemptive pair with digits {2, 6}. Removed 2 and 6 from c(2,1) and 2 and 6 from c(2,2).
preemptive setIn column 9, cells c(1,9) and c(2,9) form a preemptive pair with digits {2, 6}. Removed 2 from c(6,9).
preemptive setIn box 8, cells c(8,4) and c(8,6) form a preemptive pair with digits {2, 6}. Removed 2 from c(9,4) and 2 from c(9,5).
14c(9,4)3Only 3 left in the mark-up.
15c(3,6)3The only place for 3 in row 3.
16c(4,6)7The only place for 7 in column 6.
17c(1,5)7The only place for 7 in column 5.
preemptive setIn row 9, cells c(9,3) and c(9,5) form a preemptive pair with digits {4, 5}. Removed 4 and 5 from c(9,1), 4 and 5 from c(9,2) and 4 from c(9,8).
18c(9,8)9Only 9 left in the mark-up.
19c(4,8)2Only 2 left in the mark-up.
20c(4,3)8Only 8 left in the mark-up.
21c(3,3)2Only 2 left in the mark-up.
22c(1,1)6Only 6 left in the mark-up.
23c(1,9)2Only 2 left in the mark-up.
24c(2,9)6Only 6 left in the mark-up.
25c(2,5)2Only 2 left in the mark-up.
26c(3,1)7Only 7 left in the mark-up.
27c(3,2)8Only 8 left in the mark-up.
28c(3,4)6Only 6 left in the mark-up.
29c(4,5)6Only 6 left in the mark-up.
30c(4,2)9Only 9 left in the mark-up.
31c(5,8)1Only 1 left in the mark-up.
32c(6,9)9Only 9 left in the mark-up.
33c(7,9)1Only 1 left in the mark-up.
34c(8,4)2Only 2 left in the mark-up.
35c(5,4)9Only 9 left in the mark-up.
36c(6,4)1Only 1 left in the mark-up.
37c(8,6)6Only 6 left in the mark-up.
38c(9,1)2Only 2 left in the mark-up.
39c(9,2)7Only 7 left in the mark-up.
40c(5,2)6The only place for 6 in row 5.
41c(5,6)2The only place for 2 in row 5.
42c(6,6)5Only 5 left in the mark-up.
43c(6,5)3Only 3 left in the mark-up.
44c(5,5)8Only 8 left in the mark-up.
45c(6,1)4Only 4 left in the mark-up.
46c(2,1)5Only 5 left in the mark-up.
47c(2,2)4Only 4 left in the mark-up.
48c(5,1)3Only 3 left in the mark-up.
49c(5,3)5Only 5 left in the mark-up.
50c(6,2)2Only 2 left in the mark-up.
51c(7,1)9Only 9 left in the mark-up.
52c(7,2)5Only 5 left in the mark-up.
53c(7,5)4Only 4 left in the mark-up.
54c(7,8)3Only 3 left in the mark-up.
55c(8,8)4Only 4 left in the mark-up.
56c(8,3)3Only 3 left in the mark-up.
57c(9,3)4Only 4 left in the mark-up.
58c(9,5)5Only 5 left in the mark-up.

Crook recommends the reader make a copy of the marked-up grid and carry out the crossings and entries on it. I recommend the same. The table looks dry at first glance, but followed with a pencil it shows very clearly how each step is born from the previous one. In Crook's Figure 8 he notes the order of entry beside each digit as a small subscript. The solution below is in the same style.

The solution of Shortz 301, with each digit's order of entry beside it, as in Crook's Figure 8.

At no stage of this puzzle was a guess needed. Shortz's "very challenging" label is right from the point of view of someone solving with the two simple methods, since those methods stall after seven digits. For someone using preemptive sets, the puzzle flows from start to finish. A good example of how difficulty labels shift depending on which techniques they assume.

Chapter 10 of 12

Puzzles that need guessing, Mepham and Krazydad

Coloured pencils, search trees, and puzzles that need one, two or three guesses.

Preemptive sets also run out sometimes. If no unit can be split into smaller preemptive sets and the puzzle is still unsolved, Crook suggests choosing a cell and writing one of the digits in its mark-up. That is a guess. Crook calls it random choice and states its condition this way. If no preemptive set in any row, column or box can be broken into smaller preemptive sets, an empty cell must be chosen and a digit chosen at random from its mark-up. Crook also adds that the continued existence of preemptive sets shows the solution is partial, since a completed solution has no preemptive sets.

Coloured pencils

I write all consequences of a guess in a separate colour. Crook uses red for the first guess, green for a second guess starting from the end of the red path, then blue. After the guess I again proceed with preemptive sets and singletons, but every digit I write and every candidate I cross out I do with that colour's pencil. The point is to know what to undo when something goes wrong.

Definition

A Sudoku violation occurs when the same digit appears two or more times in the same row, column or box.

In practice a violation most often shows up as a cell's mark-up emptying completely. If no digit can be written in a cell, whichever I write will create a violation. In such a case my guess was wrong. Everything that colour wrote, together with everything it crossed out, is erased, and the guessed digit is removed from the options of that cell. If other digits remain among the options, I try one of them in the same colour. If no options remain, the previous colour's guess was also wrong, and I do the same erasing for the previous colour.

This is backtracking itself, just brought down to human scale. Each guess is a branch in the search tree, and the colours are a stack kept on paper. Crook also points out that these trees are not permanent structures stored in memory like binary search trees in computer science. The tree here is generated on the fly, and the paper never holds the whole tree, only one path. Since erasing can be laborious in practice, the Cornell notes suggest it is more convenient to copy the grid onto a fresh sheet before each guess.

Crook adds two more practical recommendations. If there is a preemptive pair, the guess should be made in one of its cells, because one of the two digits is certainly right and the right one will also force the pair's other cell. If there is no pair, choose the cell with the fewest options. This is the pencil-and-paper version of the rule that won the race.

Mepham's diabolical puzzle

Crook's example that needs guessing is a puzzle from a booklet Michael Mepham published in 2005. Mepham classifies the puzzle as diabolical because it requires search paths to be generated on the fly.

123456789
123456789
The puzzle Michael Mepham classifies as "diabolical", 28 clues.

First I do everything that needs no guess. Single candidates and single places write ten digits. At this stage Crook sees the preemptive pair {[4, 7], [c(2,1), c(2,9)]} in row 2 and writes that this pair isolates the singleton 9 in c(2,7). On my path the same 9 arrives as the only place for 9 in row 2. Next the preemptive triple {[2, 4, 9], [c(4,4), c(4,6), c(4,7)]} is found in row 4 and 2, 4 and 9 are crossed out of the rest of the row. Crook notes that after this crossing out the triple {[1, 3, 8], [c(4,1), c(4,2), c(4,8)]} also appears in the same row, but as the theorem above says, this triple is the complement of the first and brings no new crossing out. After that nothing moves.

Single candidates, single places and preemptive sets yield nothing beyond this point. Eleven steps entered 10 digits and 43 cells remain empty.

Time to guess. c(2,1) is part of a preemptive pair and its mark-up is {4, 7}. Crook chooses this cell and flips a coin. The Cornell notes first write 7 in the same cell, and since that attempt is instructive, I start there. Writing 7 in c(2,1) in red sends 4 to c(2,9) because of the pair, and the chain moves fast. On my path the red pencil writes 26 digits including that 7, and at the end the mark-up of c(8,9) empties completely. In the Cornell notes the same attempt ends after five digits when there is no room left for 8 in the middle right box. The two paths stall in different places, showing that a violation can be noticed in different ways, but the outcome is the same. 7 was wrong.

The attempt in the Cornell notes. With 7 written in red in c(2,1), a chain of forced steps empties the mark-up of the red-framed cell. The red path is erased entirely.

I erase everything written in red and remove 7 from the options of c(2,1). One option remains, 4. Crook's coin had come up 4 anyway. Writing 4 in red sends 7 to c(2,9) and 7 to c(3,2), and the path stalls there. The red path in Crook's paper consists of exactly these three digits. No new preemptive set appears and a second guess is needed.

After 4 in c(2,1) the red path yields only three digits and stalls again. The mark-up of c(7,8) is {4, 8}.

This time Crook chooses c(7,8). Its mark-up is {4, 8}. According to the search tree Crook draws, 4 leads to a violation and 8 to the solution. Writing 8 in green opens the puzzle from start to finish, and the green pencil writes 40 digits including that 8.

Search tree for Mepham's puzzle, three paths, one leading to the solutionc(2,1) {4, 7}47c(7,8) {4, 8}violation48violationsolution
Crook's tree for Mepham's puzzle. The chance of hitting the solution path first time by blind guessing is 1/4.

Crook's tree contains three paths. In the first guess 7 leads to a violation and 4 to a second guess. In the second guess 4 leads to a violation and 8 to the solution. The probability of hitting the solution path first time by blind guessing is 1/2 × 1/2 = 1/4, and Crook writes that the odds against choosing it are 3 to 1. In the table below you can follow, in order, the steps before the guess, Cornell's red 7 attempt, the erasing, and the steps of the green path.

StepCellDigitReason
1c(9,9)2Only 2 left in the mark-up.
2c(9,7)6Only 6 left in the mark-up.
3c(2,5)6The only place for 6 in row 2.
4c(2,4)8The only place for 8 in row 2.
5c(2,7)9The only place for 9 in row 2.
6c(7,4)5The only place for 5 in row 7.
7c(1,3)5The only place for 5 in column 3.
8c(5,5)8The only place for 8 in column 5.
9c(6,6)6The only place for 6 in column 6.
10c(1,1)2The only place for 2 in box 1.
preemptive setIn row 4, cells c(4,4), c(4,6) and c(4,7) form a preemptive triple with digits {2, 4, 9}. Removed 4 and 9 from c(4,1), 4 from c(4,2) and 4 and 9 from c(4,8).
11c(2,1)7Guess. Mark-up {4, 7}, red pencil.
12c(2,9)4Only 4 left in the mark-up.
13c(3,2)4Only 4 left in the mark-up.
14c(3,7)5Only 5 left in the mark-up.
15c(6,2)8Only 8 left in the mark-up.
16c(4,2)1Only 1 left in the mark-up.
17c(4,1)3Only 3 left in the mark-up.
18c(4,8)8Only 8 left in the mark-up.
19c(5,2)6Only 6 left in the mark-up.
20c(6,9)3Only 3 left in the mark-up.
21c(1,9)1Only 1 left in the mark-up.
22c(3,8)3Only 3 left in the mark-up.
23c(3,9)7Only 7 left in the mark-up.
24c(5,9)5Only 5 left in the mark-up.
25c(7,1)6Only 6 left in the mark-up.
26c(7,2)7Only 7 left in the mark-up.
27c(7,8)4Only 4 left in the mark-up.
28c(6,8)9Only 9 left in the mark-up.
29c(5,8)1Only 1 left in the mark-up.
30c(6,3)2Only 2 left in the mark-up.
31c(5,3)9Only 9 left in the mark-up.
32c(5,1)4Only 4 left in the mark-up.
33c(5,7)2Only 2 left in the mark-up.
34c(4,7)4Only 4 left in the mark-up.
35c(6,4)4Only 4 left in the mark-up.
36c(8,3)8Only 8 left in the mark-up.
The mark-up of c(8,9) is empty. 7 was wrong.
Everything written in red is erased and 7 is removed from the options of c(2,1).
37c(2,1)4Only one option left, written again in red.
38c(2,9)7Only 7 left in the mark-up.
39c(3,2)7Only 7 left in the mark-up.
40c(7,8)8Guess. Mark-up {4, 8}, green pencil.
41c(7,2)6Only 6 left in the mark-up.
42c(7,3)3Only 3 left in the mark-up.
43c(7,1)7Only 7 left in the mark-up.
44c(8,9)4Only 4 left in the mark-up.
45c(4,2)8The only place for 8 in row 4.
46c(6,2)4Only 4 left in the mark-up.
47c(5,2)1Only 1 left in the mark-up.
48c(4,1)3Only 3 left in the mark-up.
49c(4,8)1Only 1 left in the mark-up.
50c(5,9)5Only 5 left in the mark-up.
51c(3,7)5The only place for 5 in row 3.
52c(5,1)6The only place for 6 in row 5.
53c(6,9)8The only place for 8 in row 6.
54c(6,8)3The only place for 3 in row 6.
55c(3,8)4Only 4 left in the mark-up.
56c(5,8)9Only 9 left in the mark-up.
57c(5,3)2Only 2 left in the mark-up.
58c(5,7)4Only 4 left in the mark-up.
59c(4,7)2Only 2 left in the mark-up.
60c(6,3)9Only 9 left in the mark-up.
61c(6,4)2Only 2 left in the mark-up.
62c(8,3)8Only 8 left in the mark-up.
63c(8,5)7The only place for 7 in row 8.
64c(9,5)3The only place for 3 in row 9.
65c(1,5)4Only 4 left in the mark-up.
66c(7,5)2Only 2 left in the mark-up.
67c(3,5)9Only 9 left in the mark-up.
68c(3,4)1Only 1 left in the mark-up.
69c(1,6)3Only 3 left in the mark-up.
70c(1,9)1Only 1 left in the mark-up.
71c(3,6)2Only 2 left in the mark-up.
72c(3,9)3Only 3 left in the mark-up.
73c(7,6)4Only 4 left in the mark-up.
74c(4,6)9Only 9 left in the mark-up.
75c(4,4)4Only 4 left in the mark-up.
76c(8,6)1Only 1 left in the mark-up.
77c(8,1)9Only 9 left in the mark-up.
78c(9,1)1Only 1 left in the mark-up.
79c(9,4)9Only 9 left in the mark-up.
Solution of Mepham's puzzle. Grey handwriting came before any guess, red after the first guess, green after the second.

The whole algorithm

At the end of his paper Crook summarises the algorithm in five steps.

  1. Find all forced numbers in the puzzle.
  2. Mark up the puzzle.
  3. Search iteratively for preemptive sets in all rows, columns and boxes, taking the appropriate crossing-out action as each new set is found.
  4. This process ends either with a solution or at a point where a random choice is needed.
  5. If a solution is found, stop. If a choice is needed, make it and return to step 3.

The Cornell notes expand the same algorithm into seven steps, writing out the guessing and undoing in more detail. I include that version too, because it shows explicitly how violations and empty mark-ups are handled.

  1. Apply the single-candidate and single-place rules alternately until they make no more progress.
  2. Mark up all empty cells.
  3. Try to split each row, column and box into preemptive sets. Try to split large sets into smaller ones. With every set you find, make the crossings the occupancy theorem allows, and if anything was crossed out, try the methods of step 1 again. Continue until no new set remains or a violation occurs.
  4. If the puzzle is solved, you are done. If a violation occurred, the puzzle has no solution and again you are done. If neither, go to step 5.
  5. Choose an empty cell and write a digit from its mark-up. Give this cell a colour you have not used before and note the cell, the digit and the colour on a separate sheet.
  6. Carry out the operations of step 3, but write every digit in this colour. Continue until no new set remains, a violation occurs or a cell's mark-up empties.
  7. If the puzzle is solved, you are done. If a mark-up emptied, the choice in step 5 was wrong. Erase everything written in this colour and remove the digit you wrote in step 5 from that cell's mark-up. If the mark-up is still not empty, return to step 5. If it is empty, do the same erasing for the previous colour and keep going back until you reach a non-empty mark-up. If you never reach one, the puzzle has no solution. If none of these happened, return to step 5.

This algorithm terminates on every puzzle and either gives a solution or shows there is none, because the loop from 5 to 7 is nothing but backtracking pruned by the mark-up. Preemptive sets and singletons narrow the search a great deal, but what guarantees the algorithm always ends is, in the last resort, the right to make systematic guesses. So Crook's claim of "any Sudoku with pencil and paper" is true, but "any Sudoku without guessing" is not. Some solvers regard puzzles that need guessing as badly designed and want puzzles solvable by logic alone. Stronger techniques than preemptive sets are developed for this, and the methods books call X-Wing and Swordfish are relatives of preemptive sets that use several units at once. But there is no guarantee that any finite list of techniques will solve every puzzle without guessing, and the NP-completeness result I just described suggests such a guarantee should not really be expected as grids grow.

Any Sudoku with pencil and paper, yes. Any Sudoku without guessing, no.

Chapter 10, guessing

Krazydad's super-tough puzzle

The Cornell notes give the reader one more puzzle to try the algorithm on. It is the first puzzle in Krazydad's book of super-tough puzzles, and the notes suggest setting aside several hours for it. The puzzle has a unique solution.

Puzzle, 24 clues

123456789
123456789

Solution

The first puzzle in Krazydad's super-tough book. The solution grid in the Cornell notes prints the second row as 8 8 1 by mistake, it should be 8 3 1.

The single-candidate and single-place rules write 12 digits and then stop. In this puzzle preemptive sets give nothing at the first stage either. The Cornell notes also say no preemptive set was found, but several cells had only two digits in their mark-up, and they choose c(6,1). Its mark-up is {1, 9}. The notes write 1 and describe how this immediately crosses 1 out of many cells, after which the two simple methods fill several more cells. When progress stops they choose c(3,9), mark-up {3, 7}, and write 3. According to the notes, the two simple methods and preemptive sets then finish the puzzle.

When I made the same two guesses I saw something different. My own solver uses only single candidates, single places and preemptive sets confined to a single unit. With these tools, writing 1 in c(6,1) brings only one more digit, writing 3 in c(3,9) brings 17 more, but 25 cells are still empty and a third guess is needed. The cell with the fewest options is c(1,4), mark-up {3, 9}. In blue I first try 3. After 13 more digits a cell's mark-up empties. I erase the blue, write 9, and this time 24 more digits finish the puzzle. That I needed three guesses where the notes needed two may be because the author of the notes spotted by eye an elimination that uses two units at once, which my solver lacks. For the algorithm it makes no difference, both paths reach the same solution.

Back to Crook's first example

I gave the first puzzle Crook uses in his paper to illustrate the mark-up, along with its mark-up, at the start of the preemptive set section. Crook does not solve this puzzle, he only uses it to show what a mark-up looks like. Out of curiosity I tried it with my own solver, and the result was a little surprising.

In this 28-clue puzzle the two simple methods write only six digits. In c(2,7) only 7 is left in the mark-up, and Crook's mark-up also shows a lone 7 in that cell. Next the only places for 7 in row 1, for 1 in row 2, for 4 in column 4, for 5 in column 5 and for 1 in column 6 are found. Then everything stops, and this time none of the preemptive sets inside a single unit brings any new crossing out. The puzzle stalls earlier than Shortz's "very challenging" number 301.

At this point one of the cells with the fewest options is c(1,5), with mark-up {2, 3}. Following Crook's advice I write a digit in this cell in red. Writing 2 opens the puzzle from start to finish in 47 digits. Had I written 3, a mark-up would have emptied somewhere along the chain. I tried that separately too, and that is indeed what happens. So with the tools I use, this puzzle needs exactly one guess. Someone with stronger techniques might skip the guess, but within the skeleton of Crook's algorithm this puzzle sits in the middle, needing one guess fewer than Mepham's and one more than Shortz 301.

StepCellDigitReason
1c(2,7)7Only 7 left in the mark-up.
2c(1,6)7The only place for 7 in row 1.
3c(2,4)1The only place for 1 in row 2.
4c(3,4)4The only place for 4 in column 4.
5c(9,5)5The only place for 5 in column 5.
6c(7,6)1The only place for 1 in column 6.
7c(1,5)2Guess. Mark-up {2, 3}, red pencil.
8c(3,6)3Only 3 left in the mark-up.
9c(5,5)3Only 3 left in the mark-up.
10c(1,1)3The only place for 3 in row 1.
11c(6,9)3The only place for 3 in row 6.
12c(7,4)3The only place for 3 in row 7.
13c(9,4)6Only 6 left in the mark-up.
14c(6,4)7Only 7 left in the mark-up.
15c(4,4)2Only 2 left in the mark-up.
16c(8,6)2Only 2 left in the mark-up.
17c(8,1)9Only 9 left in the mark-up.
18c(4,8)7The only place for 7 in row 4.
19c(5,2)7The only place for 7 in row 5.
20c(9,3)3The only place for 3 in row 9.
21c(8,3)6Only 6 left in the mark-up.
22c(8,8)5Only 5 left in the mark-up.
23c(3,8)9Only 9 left in the mark-up.
24c(8,7)3Only 3 left in the mark-up.
25c(7,1)4The only place for 4 in column 1.
26c(7,9)6Only 6 left in the mark-up.
27c(7,8)8Only 8 left in the mark-up.
28c(7,2)2Only 2 left in the mark-up.
29c(9,2)8Only 8 left in the mark-up.
30c(3,2)5Only 5 left in the mark-up.
31c(1,2)4Only 4 left in the mark-up.
32c(1,8)6Only 6 left in the mark-up.
33c(1,7)5Only 5 left in the mark-up.
34c(2,2)9Only 9 left in the mark-up.
35c(2,3)2Only 2 left in the mark-up.
36c(2,9)4Only 4 left in the mark-up.
37c(3,1)8Only 8 left in the mark-up.
38c(3,9)2Only 2 left in the mark-up.
39c(5,8)1Only 1 left in the mark-up.
40c(4,9)5Only 5 left in the mark-up.
41c(4,1)1Only 1 left in the mark-up.
42c(5,1)2Only 2 left in the mark-up.
43c(5,9)9Only 9 left in the mark-up.
44c(5,3)8Only 8 left in the mark-up.
45c(5,7)6Only 6 left in the mark-up.
46c(4,7)8Only 8 left in the mark-up.
47c(4,6)6Only 6 left in the mark-up.
48c(6,1)5Only 5 left in the mark-up.
49c(6,2)6Only 6 left in the mark-up.
50c(6,3)9Only 9 left in the mark-up.
51c(6,6)8Only 8 left in the mark-up.
52c(9,8)4Only 4 left in the mark-up.
53c(9,9)1Only 1 left in the mark-up.
Solution of Crook's first example. Grey handwriting came before the guess, red digits followed the 2 written in c(1,5).

Put side by side, these puzzles show how relative difficulty labels are. The puzzle Shortz calls very challenging falls to preemptive sets without a guess. Crook's own first example, innocent as it looks on the page, needs one guess. Mepham's diabolical puzzle needs two. Krazydad's super-tough puzzle needs three with my tools, one of them wrong. There is no single right way to measure a puzzle's difficulty, and most puzzle-generating programs set difficulty according to which techniques are needed to solve the puzzle.

A championship with two solutions

A footnote in Crook's paper brings unavoidable sets before me once more. Crook writes that some experts argue Sudoku puzzles should have unique solutions but that this view is not universal, and he gives an example. The puzzle with which the American Thomas Snyder won the 2007 World Sudoku Championship final in Prague has exactly two solutions. Crook finds both and shows they differ only in a 2×2 square straddling boxes 5 and 6, with 6 and 8 swapping places at the corners. This is the same as the four-cell rectangle from the unavoidable sets section. Crook solves the puzzle with his own algorithm in under an hour. According to The Times, Snyder took about five minutes, checking included.

Chapter 11 of 12

Sudoku is really a graph colouring problem

81 vertices, 810 edges, nine colours and the chromatic polynomial.

The last section of the Cornell notes opens with a confession. Sudoku has mathematical aspects, but it is not one of the main subjects of research mathematicians and probably never will be. I agree, but I agree even more with the observation that follows. An important part of the theory of Sudoku had already been built, in a far more general language, long before the puzzle became popular in the West. That language is graph theory.

What is a graph?

A graph is a structure made of points and lines joining some pairs of points. The points are called vertices and the lines edges. A graph can have a single vertex or millions, it can have no edges at all or every pair of vertices joined. A graph is an abstract object, but vertices and edges usually stand for something. Vertices can be cities and edges the roads between them. Vertices can be people and edges friendships. Vertices can be computers in a network and edges the cables joining them.

The basic definition has two common variants. In a directed graph each edge has a direction and is drawn as an arrow. The circulatory system is a good example. Arteries and veins are edges, the points where vessels meet are vertices, and since blood flows in one direction in each vessel, each edge can be given a direction. In a weighted graph each edge carries a number. When I draw a road network as a graph, that number might be the length of the road, in a pipe network the most water a pipe can carry.

The beginning of graph theory is usually traced to Euler's 1736 paper solving the bridges of Königsberg problem. The river through the city separated four land masses, joined by seven bridges. The question was whether there is a walk crossing every bridge exactly once. Euler thought of the land masses as vertices and the bridges as edges, and looked at the number of edges at each vertex, its degree. He showed that for such a walk the number of odd-degree vertices must be zero or two. In Königsberg all four vertices had odd degree and the walk was impossible. The argument needs no advanced mathematics, but because it tears the problem away from the map and reduces it to connections alone, it counts as the beginning of an entire field.

Today graph algorithms are used when a route-planning app computes the shortest route between two cities, when an electricity company decides where to run new lines, when planning for a postman to pass along every street at least once and return to the post office by the shortest route, and when computing the largest traffic a data network can carry. The Cornell notes list these classic problems in an exercise. The Chinese postman problem seeks the shortest walk that passes every edge at least once and returns to the start. The shortest path problem seeks the lowest-weight path between two vertices. The travelling salesman problem seeks the shortest tour visiting every vertex and returning to the start, and it is NP-hard. The max-flow min-cut theorem says the largest flow that can be carried between two points of a network equals the capacity of the weakest cut separating them. None of these was developed for Sudoku. But once Sudoku is turned into a graph, part of this inheritance enters Sudoku's service without any effort.

The Sudoku graph

To turn Sudoku into a graph I put a vertex on each cell, 81 vertices. I join by an edge any two cells that share a row, column or box, that is, that cannot hold the same digit. The drawing at the very top of the article is exactly this graph, and tapping a vertex shows all its edges.

The numbers of this graph are easy to compute. Every cell has 8 neighbours in its row and 8 in its column. It has 8 more in its box, but 2 of those are in the same row and 2 in the same column, already counted, which leaves 4 new neighbours. The total degree is 8 + 8 + 4 = 20. Every vertex has the same degree, so the graph is regular. Each of the 81 vertices sits on 20 edges, and since each edge is counted twice, once from each end, the number of edges is

81 × 20 / 2 = 810

With the show-all-edges button in the opening drawing you can see all 810 edges at once. Drawn with that many edges the graph looks like woven cloth and following individual edges becomes impossible. The Cornell notes also say that with 81 vertices and several hundred edges the graph is too large to draw and suggest thinking about it without drawing. A smaller example shows the idea more clearly. The graph of 4×4 Sudoku has 16 vertices. Each vertex has 3 neighbours in its row, 3 in its column and 1 more in its box, so every vertex has degree 7 and there are 16 × 7 / 2 = 56 edges.

1234341221434321
The graph of 4×4 Sudoku. 16 vertices, 56 edges. Orange arcs join cells in a row, blue arcs cells in a column, straight green lines join cells that share only a box. The vertices are coloured as in a solved grid and no edge has both ends the same colour.

Colouring

I think of the digits as nine colours. 1 is red, 2 is orange and so on. Writing a digit in a cell means painting that vertex that colour. The Sudoku rule, that two cells in the same unit may not take the same digit, means that two vertices joined by an edge may not be painted the same colour. In graph theory a colouring in which no pair of joined vertices gets the same colour is called a proper colouring. So a filled Sudoku is a proper colouring of the Sudoku graph with nine colours.

There is a small detail here. Sudoku wants each digit exactly once in each unit, while proper colouring only wants neighbouring vertices to have different colours. Are these the same? The nine cells of a row form nine mutually joined vertices. In graph theory a subgraph in which every vertex is joined to all the others is called a complete subgraph or clique, and in a nine-vertex clique all nine vertices must get different colours. Since there are only nine colours, each colour is used exactly once. The same holds for every column and every box. So a proper colouring with nine colours is the same as using every colour exactly once in every unit. This also shows the graph cannot be properly coloured with fewer than nine colours. The least number of colours needed for a proper colouring is called the chromatic number, and the chromatic number of the Sudoku graph is 9.

A puzzle, then, is a partly coloured graph. The clue cells are already coloured and the task is to extend the colouring to the remaining vertices without breaking properness. In the game below you can colour the opening puzzle as a graph. When you try to give a vertex the same colour as a neighbour, it shows whether the two vertices are in the same row, column or box, that is, where the edge between them comes from. Turning on the mark-up shows the colours still available at each empty vertex. That is the graph-language version of Crook's mark-up, the colours not yet used by a vertex's neighbours.

4
6
3
8
2
5
3
7
4
9
8
4
3
2
3
1
9
4
5
7
1
5
6
4
7
9
1
4
8
3
6
4
7
8
5
1
3
9
2

Pick a colour and tap an empty cell. Tapping a cell you coloured removes its colour.

The opening puzzle as a graph. Ringed discs are the given clues. A cell that tries to take a neighbour's colour is marked in red together with that neighbour. With mark-up on, each empty cell shows the colours still available to it.

The chromatic polynomial

This translation is not just a nice analogy, because it puts nearly three hundred years of graph theory at Sudoku's disposal. The most striking example is the chromatic polynomial.

A graph G and a number λ are given. How many ways are there to properly colour G with at most λ colours? I write this number P(G, λ). I start with small examples. In a triangle of three vertices, each joined to the other two, I can give the first vertex one of λ colours, the second one of the λ − 1 colours different from the first, and the third one of the λ − 2 colours different from the first two.

P(triangle, λ) = λ(λ − 1)(λ − 2)

In a path of three vertices, where b and c are both joined to a but not to each other, a gets one of λ colours, b one of the λ − 1 colours different from a, and c also one of the λ − 1 colours different from a. There is no harm in c having the same colour as b.

P(path, λ) = λ(λ − 1)2

Both results are polynomials in λ, and that is no accident. George Birkhoff showed in 1912 that the number of colourings of any graph is a polynomial in λ. The proof rests on a relation called deletion and contraction. I consider two vertices b and c that are not joined by an edge. In a proper colouring these two vertices are either different colours or the same colour. The colourings where they differ are the proper colourings of the graph obtained by joining b and c with an edge. The colourings where they are the same are the proper colourings of the graph obtained by merging, or contracting, b and c into a single vertex. The sum of these two numbers gives the number of colourings of the original graph.

Path, P = λ(λ − 1)²

abc

b joined to c, triangle, λ(λ − 1)(λ − 2)

abc

b and c merged, λ(λ − 1)

abc
The smallest example of deletion and contraction. The number of colourings of the path on the left equals that of the triangle in the middle plus that of the one-edge graph on the right.

I can check this relation on the path example. Joining b and c gives a triangle with λ(λ − 1)(λ − 2) colourings. Merging b and c leaves two vertices joined by an edge, with λ(λ − 1) colourings. The sum is λ(λ − 1)(λ − 2) + λ(λ − 1) = λ(λ − 1)(λ − 1), exactly the path's number of colourings. Applying this relation again and again, I can break every graph into graphs with the same number of vertices and more edges, or fewer vertices, and the breaking ends at complete graphs or single vertices. Since every step gives a polynomial, the result is a polynomial.

abc

Path, λ(λ − 1)²

12

abc

Triangle, λ(λ − 1)(λ − 2)

6

abc

b and c merged, λ(λ − 1)

6

12 = 6 + 6 ✓

Slide λ and the three counts change, but the path always equals the triangle plus the merged graph. That identity, applied again and again, is why every graph has a chromatic polynomial.

The theorem of Herzberg and Murty

In their 2007 paper in the Notices of the AMS, Agnes Herzberg and Ram Murty extend the chromatic polynomial to partially coloured graphs. Crook relies on this result in the last section of his paper as well.

Completion chromatic polynomial theorem

Let G be a finite graph with v vertices. Let C be a partial colouring of t vertices of G using d0 different colours. Let pG,C(λ) be the number of ways to complete this colouring to a proper colouring with λ colours. Then for λ ≥ d0, pG,C(λ) is a monic polynomial of degree v − t with integer coefficients.

For Sudoku, v = 81, t is the number of clues and d0 the number of different digits used in the clues. A puzzle having a unique solution means pG,C(9) = 1. The coefficients of this polynomial can be computed by running the inductive proof of the theorem as a program, and that proof is essentially deletion and contraction. I see it as a general machine that gives the number of solutions of a puzzle without any Sudoku-specific trick. In the same paper Herzberg and Murty also prove that for a unique solution the clues must use at least eight different colours, that is d0 ≥ 8. That is the result I showed in the unavoidable sets section by swapping two missing digits.

That the polynomial has degree v − t also fits intuition. For very large λ the colours are so plentiful that the neighbour rule barely constrains anything, and each empty vertex has about λ options. Since there are v − t empty vertices, the number of colourings grows like λv−t. The other terms of the polynomial are the corrections brought by the neighbour rule.

Where two numbers meet

In an empty grid with no clues, this polynomial becomes the ordinary chromatic polynomial of the Sudoku graph. Its value at 9 is the number of ways to properly colour the 810-edge graph with nine colours. As I just showed, every proper colouring with nine colours is a filled Sudoku and every filled Sudoku is a proper colouring. So this value is the number of filled Sudokus itself.

P(Sudoku graph, 9) = 6,670,903,752,021,072,936,960

The same holds for 4×4, and the value at 4 of the chromatic polynomial of the 56-edge graph is the 288 I counted by hand in the warm-up. The number Felgenhauer and Jarvis had a computer count in 2005 is also the number of colourings of a graph.

Chapter 12 of 12

Try it yourself

Eight exercises built on the ideas above, each with a folded solution.

The Cornell notes place exercises inside each section for the reader to solve alone, and I think these topics sink in much better with a pencil in hand. Below are eight exercises built on the ideas in this article. Each solution is folded away underneath, and I suggest trying first and opening it afterwards.

Exercise 1. A 4×4 Sudoku has first row 1 2 3 4 and second row 3 4 2 1. Find the two ways to complete the bottom two rows and explain why there is no third.

Show the solution

The top halves of the columns hold {1, 3}, {2, 4}, {3, 2} and {4, 1}, so the bottom halves are missing {2, 4}, {1, 3}, {1, 4} and {2, 3} respectively. If I write 2 in c(3,1), then 4 goes to c(4,1). With c(3,1) = 2 in the bottom-left box, {1, 3} remains for c(3,2) and c(4,2), and together with c(4,1) = 4 the box will be {1, 2, 3, 4}. Since the third row starts with 2 and c(3,3) and c(3,4) have options {1, 4} and {2, 3}, c(3,4) cannot be 2, so it is 3, c(3,3) is 4 and the third row comes out as 2 1 4 3. The fourth row is then 4 3 1 2. If I write 4 in c(3,1), the same chain makes the third row 4 3 1 2 and the fourth 2 1 4 3. Since c(3,1) can only be 2 or 4 and each choice determines the rest uniquely, there is no other way.

Exercise 2. Prove directly that a 9×9 Sudoku cannot have a two-cell unavoidable set, that is, a solvable puzzle with only two empty cells always has a unique solution.

Show the solution

Suppose swapping the digits of two cells gives a new solution. The digits in the two cells must differ, otherwise the grid does not change. If the cells are not in the same row, the first cell's row loses its own digit after the swap and gains the second cell's digit. That row already has the second cell's digit elsewhere, since it contained every digit from 1 to 9 to begin with. That is a violation. So the two cells are in the same row. By the same reasoning they must be in the same column. Two different cells cannot lie in the same row and the same column.

Exercise 3. In the twelve-cell improvement of the counting section, why is c(9,9) not on the list, and why does this improvement lower the bound by only nine digits?

Show the solution

c(9,9) is the last cell of its row and the row table already gives it the value 1. Adding it would not change the product. The improvement stays limited because it only catches cells with a single option. For c(9,1), for example, the row table says 9 while really there is 1 option, which is a big gain. But for c(8,1) the row table also says 9, whereas the column rule allows only 2 options. Differences in cells like this are only caught when taking the minimum of the three tables, and then the bound drops from 3.8 × 1041 to 1.53 × 1031.

Exercise 4. In your friend's fourteen-clue puzzle the clues use the digits {1, 2, 3, 5, 6, 7, 8, 9}, eight different digits. Can the eight-digit rule show this puzzle is not uniquely solvable? How do I know it is not uniquely solvable without any calculation?

Show the solution

The eight-digit rule cannot show it, because only one digit, 4, is missing from the clues and a swap needs two missing digits. I know the puzzle is not uniquely solvable from the theorem of McGuire, Tugemann and Civario. If no uniquely solvable puzzle exists even with 16 clues, none can exist with 14, since adding two more clues to a uniquely solvable 14-clue puzzle would turn it into a uniquely solvable 16-clue puzzle.

Exercise 5. You notice that in a box the digit 5 can only go into cells in row 2 of that box. Prove that with this information you can cross 5 out of the cells of row 2 outside the box. Can Crook's single-unit preemptive sets always catch this elimination?

Show the solution

The box must contain 5 exactly once, and 5 can only go into row 2 within the box. So in the solution, row 2's 5 is inside this box. Since a row can contain 5 only once, its cells outside the box cannot hold 5. Puzzle books call this technique a locked candidate. It cannot always be caught by looking at preemptive sets inside one box, because the cells carrying 5 may have other candidates too, and these cells may not form a preemptive set with the rest of the box. That may be why my solver had to make one more guess than the author of the notes on the Krazydad puzzle.

Exercise 6. Change the simple solving algorithm so that it counts how many solutions a puzzle has. Describe the change in terms of the algorithm's steps.

Show the solution

In step 4, when a suitable digit is written in the last cell, instead of stopping, increase a counter by one. Then erase the digit in the last cell, make the previous cell in the list the current cell and continue from step 3 by increasing its digit, as if you had hit a dead end in the last cell. The algorithm stops when the first cell also goes past 9, and the counter shows the number of solutions. If you only want to check uniqueness you can stop when the counter reaches 2.

Exercise 7. In the graph of 16×16 Sudoku, what is the degree of each vertex and the total number of edges? What is the chromatic number of the graph?

Show the solution

Each vertex has 15 neighbours in its row and 15 in its column. It has 15 neighbours in its 4×4 box, of which 3 are in the same row and 3 in the same column, leaving 9 new neighbours. The degree is 15 + 15 + 9 = 39. With 256 vertices the number of edges is 256 × 39 / 2 = 4,992. Since a row forms a 16-vertex clique, the chromatic number is 16. In general, for Sudoku with box side n the degree is 3n2 − 2n − 1, for 9×9 that is 27 − 6 − 1 = 20.

Exercise 8. Using deletion and contraction, find the chromatic polynomial of a four-vertex cycle, the graph whose vertices a, b, c, d are joined in order and d is joined to a. In how many ways can you colour this cycle with two colours?

Show the solution

This time I use the relation on an edge. A graph with an edge is obtained from the colourings of the graph with that edge deleted, minus the colourings in which the two ends of the edge get the same colour, and those are the colourings of the graph with the edge contracted. Deleting the edge between d and a leaves a four-vertex path with λ(λ − 1)3 colourings. Merging d and a gives a triangle with λ(λ − 1)(λ − 2) colourings. The difference is λ(λ − 1)[(λ − 1)2 − (λ − 2)] = λ(λ − 1)(λ2 − 3λ + 3). For λ = 2 this is 2 × 1 × (4 − 6 + 3) = 2. Indeed a four-vertex cycle can be coloured with two colours in only two ways, alternating the colours.

Sources

  1. J. F. Crook, A Pencil-and-Paper Algorithm for Solving Sudoku Puzzles, Notices of the AMS 56(4), 2009, 460–468.
  2. B. Felgenhauer and F. Jarvis, Mathematics of Sudoku I, Mathematical Spectrum 39, 2006, 15–22.
  3. E. Russell and F. Jarvis, Mathematics of Sudoku II, Mathematical Spectrum 39, 2006, 54–58.
  4. G. McGuire, B. Tugemann and G. Civario, There Is No 16-Clue Sudoku, Solving the Sudoku Minimum Number of Clues Problem via Hitting Set Enumeration, Experimental Mathematics 23(2), 2014, 190–217.
  5. A. M. Herzberg and M. R. Murty, Sudoku Squares and Chromatic Polynomials, Notices of the AMS 54(6), 2007, 708–717.
  6. T. Yato and T. Seta, Complexity and Completeness of Finding Another Solution and Its Application to Puzzles, IEICE Transactions on Fundamentals E86-A(5), 2003, 1052–1060.
  7. G. Tarry, Le problème des 36 officiers, 1900.
  8. D. E. Knuth, Dancing Links, 2000.
  9. P. Meerkamp, Mathematics and Sudokus, Cornell Mathematics Explorers' Club, 2009.