Written by Brian Hamilton and Karan Hamilton.
Brian and Karan are the puzzle lovers and game makers behind Sudoku Online Puzzles. You can learn more on the About page.
Guides are reviewed for clarity, accuracy, and usefulness for solvers. See our editorial standards, puzzle testing process, or send a correction.
A sudoku is full of digits and never adds any of them. The mathematics in it is counting and proof: how many ways the grid can be filled, which of those grids are the same one in disguise, and how few clues can pin a single answer down. The big numbers come from the papers that found them, linked below. Where a figure can be checked on an ordinary computer we checked it with our own scripts, and both diagrams use real boards from the puzzle lists this site deals from.
Is sudoku a maths puzzle?
Only in the way logic is maths. The nine digits are labels: a puzzle never adds, compares or orders them, and swapping them for nine letters, as our Wordoku does, changes nothing about how it is solved. What a sudoku asks for is proof. Each placement is a small deduction, either “this square can’t be anything else” or “this digit can’t go anywhere else in this row”, and the techniques solvers learn, from naked singles upwards, are named patterns of that reasoning. Our guide to sudoku techniques sets them out in order.
How is a sudoku grid put together?
A grid has 81 squares and 27 houses: nine rows, nine columns and nine boxes, each of which must hold 1 to 9 once. Every square sits in exactly three houses and shares a house with exactly 20 other squares, its peers: eight in its row, eight in its column and four more in its box.
Mathematicians draw this as a graph, a point for each of the 81 squares and a line between every pair of peers, which comes to 810 lines. In graph theory’s terms, a finished sudoku gives each of the 81 points one of nine colours so that no line joins two points of the same colour, and a puzzle hands you some of the colours in advance (Wikipedia: Mathematics of Sudoku). Our counts of these, and the bigger figures below, are in the table.
| Figure | Value | Where it comes from |
|---|---|---|
| Squares, houses, peers per square | 81, 27, 20 | Counted by us |
| Lines in the sudoku graph | 810 | Counted by us |
| Exact-cover matrix | 729 rows × 324 columns | Counted by us |
| Ways to fill the top band | 948, | Counted by us (2,612,736 × 9!) |
| Completed 9×9 grids | 6, | Felgenhauer and Jarvis, 2005 |
| Essentially different grids | 5, | Russell and Jarvis |
| Latin squares of order 9 | 5, | OEIS A002860 |
| Fewest clues for one answer | 17 | McGuire, Tugemann and Civario, 2012 |
“Counted by us” means worked out by tools/measure/posts/grid-counts.js in our repository, which fills in every grid it counts. The other rows are cited in the sections below.
Is every Latin square a sudoku?
No, and the gap is enormous. A Latin square of order 9 is a 9×9 grid with each symbol once in every row and every column; sudoku adds the boxes. There are 5,524,751,496,156,892,842,531,225,600 Latin squares of order 9 (OEIS A002860) and 6,670,903,752,021,072,936,960 sudoku grids, so only about one Latin square in 828,186 has all nine boxes complete. The pair below shows how little it takes to lose them.
Swapping rows 1 and 2 instead would have kept every box whole, because those two rows share a band. That is the rule behind the next two sections: shuffling rows within a band, or whole bands, always turns a sudoku grid into another one; moving a row across bands is not guaranteed to, and here it broke six boxes.
How many sudoku grids are there?
6,670,903,752,021,072,936,960, about 6.67 × 1021. Bertram Felgenhauer and Frazer Jarvis worked it out by computer in 2005 (Cornell Math Explorers’ Club). Nobody could list that many grids, so the trick was to count far fewer and multiply, as Cornell’s walk-through of their method explains:
- Fix the first box. Relabel the digits so the top-left box reads 1 to 9 in order. Each grid can be relabelled that way in exactly one way, so the total is 9! = 362,880 times the number of grids with that box fixed.
- Count the top band. Around that box, rows 1 to 3 can be finished in 2,612,736 ways. Our script fills in every one of them and gets the same number; times 9!, that makes 948,109,639,680 possible top bands.
- Group what’s the same. Many top bands allow exactly the same number of ways to finish the grid, so they were sorted into classes, and only 44 classes needed a computer search of the six rows below.
The answer factors as 220 × 38 × 5 × 7 × 27,704,267,971, where the last number is prime; we checked the factors ourselves. Smaller grids can simply be filled in every possible way, and our 4×4 sudoku and 6×6 sudoku pages did exactly that.
| Grid | Completed grids | Essentially different |
|---|---|---|
| 4×4 (2×2 boxes) | 288 | 2 |
| 6×6 (2×3 boxes) | 28,200,960 | 49 |
| 9×9 (3×3 boxes) | 6, | 5, |
Completed 4×4 and 6×6 grids counted by filling in every one, on our 4×4 and 6×6 pages and again by grid-counts.js; their essentially different counts are from those pages. The 9×9 counts are Felgenhauer and Jarvis’s and Russell and Jarvis’s.
How many essentially different sudoku grids are there?
5,472,730,538, a count by Ed Russell and Frazer Jarvis (OEIS A109741). Two grids count as the same if one turns into the other under moves that always keep a grid valid:
- relabel the digits, in 9! ways;
- shuffle the rows inside each band, shuffle the three bands, and do the same for columns and stacks: 68 ways;
- reflect the grid across its diagonal, or not: 2 ways. A quarter turn is a reflection plus a column shuffle, so turning is already included.
That is 1,218,998,108,160 moves in all, the figure Wikipedia gives. Divide the number of grids by it and you get about 5,472,447,994, which is close but 282,544 short. The shortfall is the interesting part. A few grids are their own disguise: some move other than doing nothing gives back exactly the same grid. Such a grid has fewer distinct copies than the average, so plain division undercounts the families. Russell and Jarvis corrected for it with Burnside’s lemma, a counting theorem made for exactly this, as McGuire’s team describes their work in the 17-clue paper below.
What are unavoidable sets in sudoku?
An unavoidable set is a group of squares in a finished grid whose digits could be rearranged, with everything else left as it is, to give another valid grid. The smallest have four squares: a rectangle across two rows, two columns and two boxes, with the same two digits on its opposite corners. Gary McGuire, Bastian Tugemann and Gilles Civario put the consequence in one line: “any set of clues for a proper puzzle must use at least one clue from every unavoidable set” (arXiv 1201.0749). If a rectangle had no clue in it, its two digits could change places and the puzzle would have two answers.
The puzzle above is not unusual. We searched the answer to every puzzle on our 17-clue list: 49,054 of the 49,158 contain at least one unavoidable rectangle, one of them 19, and every rectangle in every answer holds at least one of its 17 clues. The same check passes on all 10,000 puzzles behind our Evil and Extreme pages.
The same idea settled the minimum. For every one of the 5,472,730,538 essentially different grids, McGuire’s team searched for sets of 16 squares that touch every unavoidable set, the only arrangements a 16-clue puzzle could use, and found none whose clues gave one answer. “With our new algorithm, this computation actually took only about 800 processor-years”, they write, run as a year-long search at the Irish Centre for High-End Computing. They posted the result on 1 January 2012, and it was published in Experimental Mathematics in 2014. Puzzles with 17 clues do exist, and our 17-clue sudoku page deals from 49,158 of them, but not every grid has one: in July 2026 David Eppstein and Xinyu Zhang constructed a grid that needs 18.
How do computers solve sudoku?
The usual way is a depth-first search: put a digit in the square with the fewest options left, carry on, and back up when some square has none. That is what our Sudoku Solver does. Once it has an answer it keeps searching until it finds a second one or runs out of options, which is how it can tell you whether your puzzle has one answer or several.
The tidier way recasts sudoku as an exact cover problem. Make a table of 0s and 1s with a row for each possible placement, a digit in a square, and a column for each rule: each square filled, and each digit once in each row, column and box. That is 729 rows and 324 columns, each row has exactly four 1s, and a solution is a choice of 81 rows that covers every column exactly once (Wikipedia: Exact cover). Donald Knuth’s Dancing Links (2000) is the classic way to search a table like that quickly.
For a 9×9 grid neither is hard work: our own counter checked all 49,158 seventeen-clue puzzles for a second answer in less than a minute on a desktop computer. The difficulty is in the general problem. On larger grids, n2×n2 with n×n boxes, solving sudoku is NP-complete, as Takayuki Yato and Takahiro Seta showed in 2003 (Wikipedia: Sudoku), so no known method stays fast as the grid grows.
How do puzzle makers make sure there is only one answer?
By checking every digit they take out. Both of our generators start from a filled grid and remove digits one at a time, but they check in different ways:
- The game on our sudoku page proves it by solving. A removal stands only if a fixed set of steps can still finish the board: singles on Easy and Medium, plus locked candidates on Hard, plus naked pairs on Expert. Each step only strikes digits that cannot go where they are struck, so a board the steps finish has exactly one answer, and the solve is the proof.
- Our printable sudoku generator counts. After each removal it searches for answers and stops at two; if it finds only one, the removal stands.
We recounted with a separate search written for the purpose. All 800 puzzles we dealt from the game, 200 per level, have exactly one answer, the one the generator made. Easy keeps 40 clues, Medium 32, Hard 26 and Expert 22 to 25 (23 typically). The 5,000 Evil puzzles (17 to 30 clues), the 5,000 Extreme puzzles (21 to 27) and the 49,158 on our 17-clue list all have exactly one answer too.
Of the 49,158 puzzles on our 17-clue list, 39,758 (81%) can be finished with nothing beyond singles, locked candidates and naked pairs, the steps that finish every Expert puzzle we deal. Meanwhile 3,616 of our 5,000 Evil puzzles keep 26 to 30 clues, more than any of the 200 Expert puzzles we dealt, and not one of the 5,000 can be finished with those steps. Difficulty is about which deductions a puzzle forces, and how sudoku difficulty levels work explains it.
Is “math sudoku” the same thing?
Usually not. People looking for math sudoku mostly mean puzzles where arithmetic is part of the rules. Killer sudoku keeps the normal rules and adds cages whose digits must add up to a total. Calcudoku drops the boxes and gives each cage a target and an operation: add, subtract, multiply or divide. A finished Calcudoku is a Latin square, the object in the diagram pair above.
Killer’s arithmetic has maths of its own. Every house adds up to 45, which is where the rule of 45 comes from, and our killer sudoku combinations chart lists every set of digits for every cage total.