Sudoku difficulty: how we grade

We grade a sudoku by the hardest technique a person needs to solve it without guessing. Easy needs only singles. Expert needs a Swordfish, an XY-Wing or a naked quad. This page lists every technique and how the code uses them.

Updated

Most sudoku sites label difficulty by how many numbers are given. That is a weak signal. A puzzle with few givens can still fall to simple steps. We grade by what solving requires, so a level means the same thing every time. You can make puzzles at each level with the sudoku generator.

The two checks behind every puzzle

A logic solver plays the puzzle the way a person does, never guessing, and records the hardest technique it had to use. A separate exact-cover solver then proves the puzzle has exactly one solution. The two are written apart on purpose, so the proof does not repeat the generator's own assumptions.

The techniques in order

The logic solver gives each technique a rank from 1 to 4. It always tries singles first, then works up the list. The rank of the hardest technique used is the rank of the puzzle.

RankLevelTechniques
1EasyNaked single, hidden single
2MediumLocked candidates, naked pair, hidden pair
3HardNaked triple, hidden triple, X-Wing
4ExpertSwordfish, XY-Wing, naked quad

Here is what each one means in plain terms.

  • Naked single: a cell has only one digit left that can go in it.
  • Hidden single: a digit has only one cell left in a row, column or box.
  • Locked candidates: in a box, a digit can only go in one row or column, so it can be removed from the rest of that line.
  • Naked pair and hidden pair: two cells share two candidates, which removes those digits from other cells in the unit.
  • Naked triple and hidden triple: the same idea with three cells and three digits.
  • X-Wing: a digit sits in exactly two cells in each of two rows, lined up in the same two columns, so it can leave the rest of those columns.
  • Swordfish: the X-Wing pattern extended to three rows and three columns.
  • XY-Wing: three cells linked by pairs of candidates that force a digit out of any cell that sees two of them.
  • Naked quad: four cells sharing four candidates.

How a puzzle gets its level

The generator starts from a random complete grid. It removes givens one at a time, or in symmetric pairs if you ask for symmetry. After each removal two tests must pass: the fast solver still finds exactly one solution, and the logic solver can still finish the puzzle using techniques no harder than the target level. If either fails, the given is put back.

When removals are done, the puzzle must actually need a technique of the target rank. If it is easier than the level asked for, it is thrown away and the generator starts again. So a Hard puzzle always needs a triple or an X-Wing somewhere, and cannot be a lucky Easy.

Easy 9x9 puzzles get a small top-up: if the puzzle ends up sparse, a few givens are put back so it has at least 32. Easy and Medium should feel gentle.

Any puzzle the logic solver cannot finish is rejected. Every printed puzzle can be solved by reasoning, without trial and error.

Proving there is one solution

Our checker turns the puzzle into an exact cover problem and searches it with Dancing Links (DLX). The search counts solutions and stops after finding two. The puzzle passes only if the count is exactly one and that solution matches the printed answer. The checker also confirms every given matches the answer grid and the answer grid obeys the row, column and box rules. It regrades the puzzle from scratch and fails it if the stored grade or the label disagrees.

In the finished proof you see lines such as exactly one solution, solvable by logic alone, hardest step named with its level, and the number of givens. In a book, the proof report lists them for every sudoku.

Kids sizes

The builder and maker also offer 4x4 and 6x6 grids. Harder techniques barely exist on small grids, so the code caps them: 4x4 goes up to Easy, 6x6 up to Medium, and only 9x9 reaches Hard and Expert. Asking for a harder level on a small grid returns an error rather than a mislabelled puzzle.

What this means for your book

Use the levels to build a curve. A ramp from Easy to Hard gives a new solver a way in. Because levels are defined by technique, buyers who finish the Easy section will find the Medium section needs something new, not just fewer givens. See how to make a puzzle book for setting a difficulty curve.

Sudoku generatorProof method

Questions

Does a harder sudoku have fewer givens?

Not necessarily. We grade by the hardest technique needed, not by the number of givens. Easy 9x9 puzzles are kept to at least 32 givens, but the level comes from technique.

Do your sudoku ever need guessing?

No. The logic solver must finish every puzzle using the listed techniques. A puzzle it cannot finish is rejected.

How do you know a puzzle has one solution?

A separate exact-cover (Dancing Links) solver counts solutions and the puzzle passes only if it finds exactly one.

Why does 4x4 stop at Easy?

On a grid that small the harder techniques barely occur, so we cap 4x4 at Easy and 6x6 at Medium rather than label a puzzle with a level it does not earn.

Where does X-Wing sit in your grading?

At rank 3, so a puzzle whose hardest step is an X-Wing is Hard. Swordfish, XY-Wing and naked quads are rank 4 and make a puzzle Expert.