Sudoku cultureBy the Shapedoku TeamPublished 6 min read

The Math Behind Sudoku, in Plain Words

You need no mathematics to enjoy Sudoku, yet the math behind Sudoku is surprisingly rich, and none of it is scary while some of it is genuinely beautiful.

It starts with Latin squares

A Latin square is a grid in which every symbol appears once in each row and once in each column. The idea is centuries old and takes its name from Leonhard Euler, who studied such squares using Latin letters, and it turns up right across mathematics, from the design of scientific experiments to error-correcting codes. Sudoku is simply a Latin square of order nine with one extra rule bolted on top. That added constraint is the box rule: each of the nine three by three blocks must also contain every symbol exactly once. It sounds like a small addition, but it is precisely what lifts Sudoku above an ordinary Latin square and gives the puzzle its tension, because it ties the rows and columns together through the boxes. A placement in one corner can suddenly ripple into a constraint three boxes away, and that interlocking is what makes the grid worth solving. Strip the box rule out again and you are left with a pure Latin square, far easier to fill and far less interesting to sit down with.

How many grids exist

The number of complete nine by nine Sudoku grids was counted in 2005 by Bertram Felgenhauer and Frazer Jarvis. It comes to 6,670,903,752,021,072,936,960, which is about 6.67 followed by twenty-one digits, a genuinely astronomical figure for something that fits on a newspaper page. If you then decide to ignore all the rotations, reflections and relabelings that produce what is essentially the same puzzle, the count of truly distinct grids drops to 5,472,730,538, a little under five and a half billion. The distance between those two numbers is itself instructive: it shows how much of the apparent variety in Sudoku is really the same handful of deep structures seen from different angles. But either way you count, the practical conclusion is the same. The supply of boards is effectively endless for any human being, so no player will ever come close to exhausting it, and no generator ever needs to repeat itself.

The magic number seventeen

For years people wondered how few clues a proper puzzle could carry while still forcing a single answer. Puzzle enthusiasts found and traded many examples with seventeen clues, yet nobody could produce a valid puzzle with only sixteen. In 2012 a team led by Gary McGuire finally closed the question with a vast and carefully optimised computer search, proving that no sixteen-clue puzzle can ever have a unique solution. Seventeen is therefore the true floor, the smallest number of givens that can still pin a proper Sudoku down to one answer. It is a result that mixes elegant reasoning, in the clever ways the team cut the search space down to something checkable, with sheer computational muscle, in grinding through what remained. As modern mathematical facts go it is unusually satisfying, because the question is so easy to state and the answer so hard-won.

Why it is hard in general

Ordinary nine by nine Sudoku is small enough that a computer solves it in the blink of an eye, which can make the puzzle seem mathematically trivial. It is not. The generalised version, played on an n by n grid for arbitrary n, belongs to a class of problems that mathematicians call NP-complete. In plain terms, that means as the grid grows there is no known shortcut guaranteed to stay fast for every case; in the worst situations the effort required can balloon dramatically. The familiar nine by nine board simply happens to sit in a very comfortable sweet spot: it is hard enough to absorb a human solver for many satisfying minutes, yet small enough that it can always be cracked with patience and a little technique. That balance between genuine difficulty and guaranteed solvability is a large part of why the puzzle has stayed popular for so long.

Symmetry, and why shapes do not change the math

The gap between those two grid counts is worth dwelling on, because it is pure symmetry at work. You can rotate a solved board, mirror it, swap whole bands or stacks of boxes, or relabel every symbol throughout, and the underlying puzzle is entirely unchanged. Grouping all of those transformations together collapses the enormous raw count into the much smaller essentially different one, and it is the same kind of symmetry thinking that runs through great swathes of mathematics, quietly hiding inside a puzzle most people first meet in a newspaper. That final point about relabeling is also the key to Shapedoku. When the game swaps the digits one to nine for nine glowing shapes, every count and every rule above still holds exactly, because the symbols are nothing more than labels and mathematics does not care whether a cell shows a numeral or a crescent moon. The grid count, the seventeen-clue minimum, the Latin-square heritage and the NP-complete result all carry over untouched. The shapes change only how the puzzle looks and feels to a human eye; underneath sits precisely the same elegant structure that has fascinated mathematicians and players alike.

Ready to put it into practice?

Play Shapedoku free in your browser. No download, no login, just colorful shape Sudoku.

Play the Web App

Keep reading