Computer scientists have a name for the kind of problem puzzle solvers tackle every day: constraint satisfaction. Thinking in those terms, even informally, makes many puzzles easier to reason about. You don’t need any programming to use the idea. And it isn’t just theory for us: the programs we use to check every Sudoku, nonogram and logic grid on this site are constraint solvers, and what they’ve shown us about our own puzzles is a good way to explain how it works.

The Three Parts

Every constraint problem has three parts:

Naming the parts makes the job clear: shrink the domains using the constraints until every variable has one value left.

Propagation: The Engine

Propagation means using what you know to remove options elsewhere. Place a 7 in Sudoku, and every other square in its row, column and box loses 7 as a candidate. That’s exactly what you’re doing when you keep your pencil marks up to date.

Propagation is far more powerful than it sounds. When we run our 37 nonograms through a solver that does nothing but propagate (look at one line, work out every square that must be filled or empty, move to the next line, repeat), it solves 32 of them completely. No clever tricks, just thorough propagation.

The practical lesson: before you reach for an advanced technique, make sure you’ve propagated everything. A very common stall is a placed digit you never fully crossed out of its row, column and box.

Looking at a Whole Constraint at Once

Simple propagation looks at one square at a time: “what can go here?” Stronger reasoning looks at a whole constraint at once: “this row needs a 7 somewhere; where can it go?” Computer scientists call the stronger version enforcing consistency on the constraint. In Sudoku, that’s the difference between a naked single and a hidden single, and it matters enormously. On our Hard Sudoku #1, the one-square view (naked singles) can’t place a single digit at the start. The whole-row view (hidden singles) fills it to 44 squares.

Advertisement

When Propagation Runs Out: Search

If propagation can’t finish, a computer makes a choice: it tries a value, propagates again, and if it hits a contradiction, it backs up and tries the next value. That’s called backtracking, and it’s the same thing as the “what if” test human solvers use.

Our nonograms show how much of it each puzzle needs. The five that propagation can’t finish all need some testing: the Owl needs exactly one test, while the Smiley Face needs 18. That’s why the Owl is rated Medium and the Smiley Face is rated Hard.

One rule from computer science helps human solvers a lot: when you test, test the variable with the fewest options. In Sudoku, that’s a square with just two candidates. In a nonogram, it’s a square on a short, tightly packed line. The fewer the options, the faster one of them breaks, and the less you have to undo.

Checking a Puzzle Is Fair

The same tools tell us whether a puzzle is fair before we publish it:

The Takeaway

Name the variables, domains and constraints; propagate everything before you try anything clever; look at whole rows and boxes, not just single squares; and when you must test, test the square with the fewest options. That’s how a computer solves puzzles, and it’s a very good way for a person to solve them too.