The Math Behind Everything

← Articles

If you filled a Sudoku grid at random, what are the odds it would be valid?

Scatter nine 1s, nine 2s and so on up to nine 9s across a Sudoku grid at random, and the chance that no row, column or box has a repeat is about 1 in 8 followed by 48 zeros.

The setup

A Sudoku grid has 81 squares in 9 rows and 9 columns, split into nine 3-by-3 boxes. A finished board is valid when every row, every column and every box holds the digits 1 through 9 exactly once.

Now forget solving. Take 81 tiles, nine of each digit, shuffle them, and drop them into the squares. That's a board filled completely at random. It has the right number of each digit, so it looks plausible. How often would it actually be valid?

Counting every arrangement

First, count the ways to place the tiles. If all 81 tiles were different, there would be 81! ways to order them. That's 81 × 80 × 79 and so on down to 1. But the nine 1s are identical, so swapping two of them doesn't make a new board. Each digit's nine copies can be shuffled among themselves in 9! ways, so you divide that out once for each digit:

81! ÷ (9!)9 ≈ 5.3 × 1070

That's about 53 followed by 69 zeros distinct boards. Every one of them is equally likely when you shuffle.

Just getting the rows right

Start small. What are the odds that a single row comes out right? Draw 9 tiles in order from the 81. There are 81 × 80 × … × 73 ways to do that. For the row to be valid, you need one tile of each digit. There are 9 choices of which copy of each digit you draw, so 99, times 9! orders to put them in. Divide the good draws by all draws:

(81 × 80 × … × 73) ÷ (99 × 9!) ≈ 673

So one random row is valid about 1 time in 673.

For all nine rows, count the boards where every row is some ordering of 1 through 9. Each row has 9! options, so there are (9!)9 of them. Divide by all 5.3 × 1070 boards and the odds are about 1 in 490 quintillion. That's a 49 followed by 19 zeros, and you haven't checked a single column or box yet.

One detail is worth noticing. That's far better than 673 multiplied by itself nine times, which would be about 1 in 3 × 1025. The rows aren't independent. Once the first eight rows each hold one of every digit, the tiles left over are exactly one of each, so the last row is guaranteed. Each good row makes the next one a little easier.

How many valid boards exist

Columns and boxes make the count much harder to do by hand, so instead of building the odds up one rule at a time, flip the problem around. Count the valid boards directly, then divide by all boards.

Mathematicians have done that count. In 2005, Bertram Felgenhauer and Frazer Jarvis counted every valid completed Sudoku grid. There are exactly 6,670,903,752,021,072,936,960 of them, about 6.67 sextillion. That sounds like a lot. Next to the number of random boards, it isn't.

6.67 × 1021 ÷ 5.3 × 1070 ≈ 1 in 8 × 1048

So a randomly filled board is valid about once in every 8 followed by 48 zeros tries.

Putting 1048 in perspective

Numbers this big stop meaning anything, so compare it with something you can picture. There are about 8.3 billion people on Earth. Imagine one person is picked at random from all of them. The chance it's you is 1 in 8.3 billion.

Now repeat the draw. Being picked twice in a row is 1 in about 69 quintillion. Four times in a row is about 1 in 5 × 1039, which is still more than a billion times more likely than a valid random board. Five times in a row is about 1 in 4 × 1049. That finally passes the Sudoku odds, by a factor of about five.

So a random valid Sudoku board is rarer than being the one person on Earth picked four times running, and only a few times more likely than being picked five times running.

What it shows

Sudoku rules look gentle. Each one only says "no repeats here." But there are 27 of these groups, 9 rows, 9 columns and 9 boxes, and every square sits in three of them at once. Each rule cuts the pile of possible boards down, and together they cut it down by a factor of about 1048. That's why a valid Sudoku is something you build one deduction at a time and never something you stumble into.

Sources: Bertram Felgenhauer and Frazer Jarvis, "Enumerating possible Sudoku grids" (2005), for the count of valid grids; UN World Population Prospects 2024 for the 2026 world population. All other numbers are computed from the counting above.

Watch the video on YouTube, Instagram or TikTok.

For education and entertainment. Found a mistake in the math? Email me and I'll fix it.