How Sudoku Puzzles Are Generated and Solved

After reading this you can explain what makes a sudoku "proper," why difficulty comes from logic rather than the number of givens alone, and how a generator guarantees exactly one solution.

What a sudoku actually is

A standard sudoku is a 9 by 9 grid split into nine 3 by 3 boxes. You fill every cell with a digit from 1 to 9 so that each row, each column, and each box contains all nine digits exactly once. The puzzle starts with some cells already filled. Those filled cells are called the givens or clues.

A puzzle is proper when it has exactly one solution. If two different completed grids both match the givens, the puzzle is broken: at some point you would have to guess, and either guess could be right. The generator on this page checks every puzzle with a solver before showing it to you, so every puzzle it produces is proper.

Here is one hook. A completely blank grid has 6,670,903,752,021,072,936,960 valid solutions (about 6.67 \times 10^{21}). That number was computed by exhaustive search in 2005. Every proper puzzle is a set of givens that narrows all of those grids down to exactly one.

When to use a generator, and when not

Reach for a generator when you need many fresh puzzles quickly: a weekly newsletter, a classroom warm-up, a puzzle page for an event, or practice at a fixed difficulty. Each run produces a new grid, so you never hand out the same sheet twice by accident.

Do not use a generator when you want a puzzle with a specific hand-crafted pattern of givens, or a symmetric artistic layout with a guaranteed single logical path. Human setters shape those by hand. A generator optimizes for correctness and difficulty, not beauty.

If you are printing for young solvers, pick an easy level and print the solution on a second sheet. Checking answers is faster than re-solving, and it keeps a session moving.

How a proper puzzle is built

Generation runs in two stages. First, build a full valid grid. Second, remove digits one at a time, keeping the puzzle proper at every step.

The full grid comes from a backtracking fill. You place digits cell by cell, and whenever a cell has no legal digit you back up and try the next option. Randomizing the order of digits at each cell gives a different grid each time.

Then you dig holes. Pick a filled cell, remove its digit, and ask the solver: does the puzzle still have exactly one solution? If yes, keep the hole. If no, put the digit back and try another cell. The uniqueness test is the expensive part, and it is what the footnote means when it says every puzzle is checked.

C_{\text{remove}} = 81 - G

Here G is the number of givens you want to keep, and C_{\text{remove}} is how many cells you try to empty. A grid has 81 cells, so a puzzle with G = 30 givens has 51 empty cells. The generator cannot always reach an arbitrary G, because removing one more clue would create a second solution. The practical floor for a proper 9 by 9 sudoku is 17 givens: no valid puzzle with 16 or fewer has ever been found, and an exhaustive search in 2012 confirmed 17 is the minimum.

Why difficulty is not just the number of givens

People assume fewer givens means harder. It correlates, but it does not decide the matter. Difficulty is really about which solving techniques you need.

Rank the common techniques from easy to hard:

Naked single
A cell has only one digit left that fits its row, column, and box. Fill it in.
Hidden single
Within a row, column, or box, a digit can go in only one cell, even though that cell has other candidates on paper.
Locked candidate
A digit in a box is confined to one row or column, which removes it as a candidate elsewhere in that line.
Naked pair or triple
Two cells that share the same two candidates lock those digits out of the rest of their unit.
X-Wing and beyond
Patterns across two rows and two columns that eliminate candidates. These make a puzzle feel hard.

The generator sorts puzzles by the hardest technique the solver needed. A puzzle solvable with only naked and hidden singles is easy even if it has just 26 givens. A puzzle that forces an X-Wing is very hard even with 30 givens. That is why the footnote insists hard puzzles are hard because of logic, not guesswork.

Given counts drift down as difficulty rises, but the counts overlap in practice. The technique required matters more than the count.

A worked example with the demo puzzle

The demo button uses the tool defaults and produces one easy puzzle. Follow the same logic on any easy grid the tool gives you.

Solving the first three cells

Suppose the top-left box shows these givens, with dots for empty cells:

\begin{matrix} 5 & \cdot & 3 \\ \cdot & 7 & \cdot \\ \cdot & \cdot & 9 \end{matrix}
  1. Look at the center cell of this box. The box already holds 5, 3, 7, and 9. The row through that cell holds a 1 and a 4 elsewhere, and the column holds a 2. Cross those out. Only 6 remains, so it is a naked single: write 6.
  2. Now scan the whole top band for where the digit 8 can go. In box one, rows and columns block every empty cell except the top-middle. That is a hidden single: write 8.
  3. Return to the top-middle cell you just used and re-check its column. With 8 placed, the cell directly below it now has a single remaining candidate. Fill it. Each placement opens up the next.

An easy puzzle chains these two moves, naked single and hidden single, from the first cell to the last. You never have to write more than one candidate in a cell.

Reading and interpreting the result

When you solve on the page, the checker tells you whether your grid matches the unique solution. Because the puzzle is proper, "correct" means one thing only: the single valid completion. There is no partial credit for a different arrangement, because no other arrangement exists.

Hints reveal the value of one cell. Use them as a diagnostic, not a crutch. If you need a hint on an easy puzzle, you probably missed a hidden single. Scan each digit 1 through 9 across every box before you reach for help.

The widget below shows how removing givens changes the number of solutions. Watch the count jump from 1 to 2 or more the moment you remove one clue too many.

A fixed 9 by 9 solution is shown with 30 givens. Removing givens keeps the solution count at 1 until a threshold, after which the count rises: at 24 givens the sample grid still has 1 solution, but removing three specific clues to reach 21 yields 2 solutions, and reaching 18 yields 5.

Common mistakes

The first mistake is treating a guess as a technique. On a proper puzzle you never need to guess. If you feel stuck and start trying values to "see what happens," you have missed a logical step. Back up and scan for hidden singles.

The second mistake is confusing "few givens" with "hard." A puzzle with 24 givens can be easy if every step is a naked single. Judge difficulty by the technique, not the count.

Do not hand-remove clues from a printed puzzle to make it harder. Removing even one given can create a second solution and turn a proper puzzle into a broken one. Regenerate at a higher difficulty instead.

The third mistake is printing the solution on the same sheet by habit. For a contest, print the puzzle alone and keep solutions on a separate page you control.

Related tools

If you enjoy grid logic with a picture at the end, try the Nonogram Maker. It turns a pixel drawing into a picross puzzle with row and column clues. Nonograms use the same idea of a unique solution reached by pure deduction, but the clues describe runs of filled cells rather than the digits 1 through 9.

Frequently asked questions

What is the fewest clues a sudoku can have?

Seventeen. An exhaustive computer search published in 2012 checked every case and found no proper puzzle with 16 or fewer givens. Puzzles with exactly 17 do exist and tend to be hard.

Does a puzzle with more givens mean it is easier?

Usually, but not always. Given count and difficulty correlate loosely. The deciding factor is the hardest technique required. A 30-given puzzle that forces an X-Wing is harder than a 24-given puzzle solved by singles.

Can I trust that a generated puzzle has exactly one answer?

Yes. Every puzzle is run through a solver that counts solutions, and the generator keeps a puzzle only while the count stays at 1. That is the whole point of the removal test described above.

Why do two runs give different puzzles at the same difficulty?

The full-grid fill randomizes digit order at each step, and the hole-digging picks cells in a random order. Both stages use fresh randomness each run, so you get a new grid every time.

Is the generator sending my puzzle anywhere?

No. It runs entirely in your browser. Nothing leaves your device unless you choose to publish an interactive embed.