Exact Counting #mathematics #combinatorics #exact counting

Counting the uncountable, on a desktop

There are exactly 6,670,903,752,021,072,936,960 completed 9×9 sudoku grids.

That number was first computed in 2005 by Bertram Felgenhauer and Frazer Jarvis, and it's one of those facts that's easy to state and startlingly hard to establish. It's about 6.7 sextillion — more grids than there are grains of sand on Earth, by a wide margin. You cannot get there by listing them; the universe would end first. You get there by being very clever about not listing them.

I've spent about ten years building an engine for exactly this kind of problem — counting the valid members of a space so large that enumeration is physically impossible. That engine has now reproduced the sudoku number exactly, in about a day, on an ordinary desktop computer.

Then I pointed it at something harder.

An even bigger number

A Latin square of order 11 is an 11×11 grid filled with 11 symbols so that no symbol repeats in any row or column — like a sudoku grid without the box constraint, and a little bigger. A little bigger as a grid, that is; as a counting problem it is bigger by some twenty-six orders of magnitude. The number of them, L(11), was determined in 2005 by Brendan McKay and Ian Wanless, in a computation that needed purpose-built code and, for the time, serious hardware. It had been independently confirmed only once in the twenty years since.

The engine reproduced it:

L(11) = 776,966,836,171,770,144,107,444,346,734,230,682,311,065,600,000

That's roughly 7.8 × 10⁴⁷ — more than the number of atoms making up the entire Earth. Counted exactly, with no sampling and no estimate, in about eleven days on the same desktop — elapsed time, including the stretches where I paused it because I needed the machine for something else. To my knowledge, it is the third independent computation of this value in history, and the first in about fifteen years.

I want to be clear about why I find this worth writing down — because it isn't the numbers themselves.

The point isn't puzzles

This is not sudoku software, and it is not Latin-square software. It's a general-purpose engine for exact counting: give it a set of variables, the values they can take, and the rules they must obey, and it will tell you exactly how many valid configurations exist — even when that number is astronomically large.

Sudoku and Latin squares are just the proving ground. They're famously hard, and their answers are already known from independent published mathematics. That makes them perfect falsifiable tests: if the engine is wrong, it produces a number that visibly disagrees with a value the world already agrees on. There's nowhere to hide. Most of what a counting engine could ever be asked to do doesn't come with an answer key — these problems do, which is exactly why they're worth doing.

Why you should believe a big number you can't check by hand

Here's the honest problem with any long, exact computation: it hands you a single enormous number and asks you to trust it. Machines make mistakes — cosmic-ray bit flips, subtle software bugs, silent memory corruption. A wrong count that looks right is worse than no count at all.

So the engine is built to distrust itself. Throughout a computation it continuously checks its own work against facts it isn't otherwise using:

  • It reproduces every published intermediate value along the way — the counts of partial structures that McKay, Wanless, and others computed decades ago — and it does so exactly, to twenty-plus digits, or it stops.
  • It runs an independent algebraic check — a relationship the final answer must satisfy that comes from a completely different direction than the main computation, so an error in one can't quietly cancel an error in the other.
  • Before ever attempting order 11, it reproduced the smaller cases — orders 5 through 10 — each matching the known value exactly.

The rule is simple: the computation is designed to be unable to finish wrongly in silence. If anything disagrees, it halts loudly and points at the disagreement, rather than emitting a confident, wrong result. Provable correctness isn't a footnote here; it's the feature.

What it's actually for

The reason I started building this had nothing to do with mathematics competitions. It was a practical question that turns out to be everywhere: how many valid configurations does a constrained system really have?

  • A configurable product — a car, a machine, a software plan — has a space of valid variants defined by compatibility rules. How large is it, exactly? Which rule change removes exactly how many configurations? Which options are secretly dead?
  • A schedule — staff, rooms, timetables — is a space of feasible arrangements under strict constraints. How many are there, and can you pull out a specific one?

These are counting problems over huge, rule-bound spaces — the same shape as the puzzles, just wearing business clothes. And "exactly, and provably" is a genuinely different answer than "approximately, probably," in the places where it matters.

What's next

The method itself will be described in full — a paper is in preparation, and will go up on arXiv. I'd rather the how be open and checkable than a black box; for a result like this, that's the only way it earns trust. Beyond the paper, the natural frontier is L(12) — the number of order-12 Latin squares, which no one has ever computed. It's far out of reach of a single desktop today, but it's the kind of thing this engine was built to eventually reach.

For now: ten years, a desktop, and an exact answer to a question the universe is too small to answer by counting. That's a good place to stop and share the news.

If you work in configuration, scheduling, or verification — or you just want to know more — get in touch.