Direct answer: Checking that a single row holds distinct values is trivial, but the all-different constraint over many variables is a matching problem in disguise. Solvers translate it into bipartite matching and Hall's theorem, which is why general searches take longer than simple scans.

The trending query Why “all different” Sets take longer to find sits on Hacker News on November 26, 2026.

A recent discussion asked a deceptively small question: why does finding sets that are all different take longer than it seems like it should? The answer sits at the crossing point of puzzles, matchings, and one elegant theorem from 1935.

Constraints like all-different appear everywhere: sudoku rows, exam timetables, register allocation, and seat assignments. Each looks like a quick check, yet together they encode genuinely hard combinatorial structure.

One row is easy, the grid is not

Scanning nine cells for repeats is a linear pass. The difficulty appears when values interact across rows, columns, and blocks at once, because a choice that helps one constraint can quietly break another.

This coupling is what solvers call propagation. Each assignment sends ripple effects through every overlapping constraint, and the search must explore branches when ripples collide without an immediate answer.

The matching viewpoint

All-different has a classical translation: variables are one side of a bipartite graph and possible values are the other, with edges marking which value can go where. A valid assignment is a perfect matching.

Hall's theorem gives the sharp criterion: a set of variables can be matched only if, for every group of them, the union of their possible values is at least as large as the group. That single condition explains many dead ends.

Why solvers still win

Real solvers run matching algorithms inside the search loop, pruning whole branches the moment Hall's condition fails. That is why modern sudoku engines finish instantly while naive brute force wanders for ages.

The gap you feel between checking and finding is the gap between verifying one answer and searching an exponential space. Good constraints turn that exponential jungle into a guided walk.

variablesvaluestwo variables, two shared values: tight fit
TaskComplexity feelTool that helps
Check one rowTrivial scanA seen-set of values
Solve a sudoku gridCoupled searchPropagation plus backtracking
All-different broadlyMatching problemBipartite matching
Detect impossible groupsHall conditionSubset value counting
missedyour Brain mapquiz yourselfmasteredWatch your weak spots turn green.

Drop in your PDF - it doesn't leave your device.
Every miss becomes a red node on your map.
Free plan: 21 nodes, no card, no countdown.

Open Brain - free

Key takeaways

  • All-different looks like a simple check but encodes a bipartite matching problem between variables and values.
  • Hall's theorem states when a perfect matching exists: every group of variables needs at least as many combined values.
  • Solvers embed matching algorithms in their search loop, pruning impossible branches far earlier than brute force.
  • The distance between verifying an answer and finding one is the whole reason constraint engines exist.

Quick answers

What is an all-different constraint?
A rule that a group of variables must all end up with distinct values, like a sudoku row, column, or block.

Why is it harder than checking?
Checking inspects one finished answer, while finding must navigate choices whose ripples interact across overlapping constraints.

What does Hall's theorem say?
If any group of variables has fewer combined possible values than members, no valid assignment exists for that group.

Where do I meet this outside puzzles?
Timetabling, assigning frequencies, seating plans, and compiler register allocation all use the same matching structure.

One thing to do tonight

Tonight, take one sudoku row and list which candidates each empty cell allows. Circle any two cells whose candidate lists overlap exactly. You have just spotted a Hall condition in the wild, on paper, in one minute.