Skip to content
Mental Models

The No Free Lunch Theorem

Why It's True (You Can Count It)

A hand-countable toy example plus an interactive board that show two search strategies genuinely tie once you average over every problem — and the balancing act that forces the tie.

14 min Updated Jul 10, 2026

A claim this sweeping — every method ties over all problems — sounds like it must have a loophole. Surely a genuinely clever strategy sneaks a little ahead? The lovely thing about the beginner version of No Free Lunch is that you don’t have to take anyone’s word for it. On a small enough world you can count it yourself. Let’s do exactly that, then watch it happen on a bigger board.

A world you can hold in your hand

Here’s the tiniest treasure hunt that makes the point. There are three boxes in a row. A prize is hidden in exactly one of them. You open boxes one at a time until you find it, and your cost is how many boxes you had to open.

Now — where is the prize? We don’t know, so let’s be fair and consider every possibility: the prize could be in box 1, box 2, or box 3. Those three possibilities are our three “problems,” and we’ll give each equal weight (no favourites). We’ll pit two strategies against each other:

  • Lefty always opens boxes in the order 1 → 2 → 3.
  • Righty always opens them 3 → 2 → 1.

Before you read — take a guess

Quick guess: if the prize is in box 1, how many boxes does Righty (3 → 2 → 1) open before finding it?

Counting every case

Let’s tabulate the cost of each strategy on each of the three problems. This is the whole proof, and it’s just addition.

Prize is in…Lefty (1→2→3)Righty (3→2→1)
Box 11 box3 boxes
Box 22 boxes2 boxes
Box 33 boxes1 box
Total66
Average2.02.0

Stare at that for a second. Lefty is brilliant when the prize is on the left (1 box) and terrible when it’s on the right (3 boxes). Righty is the exact mirror. Every place Lefty wins, Righty loses by the same amount — and vice versa. Add it all up and both average 2.0 boxes. A dead tie.

Info:

What just happened

Neither strategy is smarter than the other; each just front-loads its luck onto different problems. Because we counted every hiding place equally, the wins and losses cancel perfectly. That cancellation is the entire mechanism behind No Free Lunch — no cleverness, just bookkeeping.

Say why the tie happens.

Pick the right option for each blank, then check.

Lefty and Righty tie because every problem where one of them is exactly balanced by a problem where it , once we count hiding place equally.

Try to cheat — you can’t

“But,” you might say, “let me invent a cleverer order!” Go ahead. Any fixed order you pick — 2 → 1 → 3, or 3 → 1 → 2, anything — still opens the prize box first on exactly one of the three problems, second on one, and third on one. Its costs are always some arrangement of 1, 2, and 3, which always add to 6 and always average 2.0. There is nowhere for a free advantage to hide.

That’s the counting version of the theorem: once every problem gets equal weight, all fixed strategies have the same total, so they can’t help but tie.

You invent a third strategy that opens boxes in the order 2 → 3 → 1. What's its average cost over the three equally-weighted problems?

Now watch it on a bigger board

Three boxes were easy to count by hand. Does the tie survive with more boxes and sneakier-looking strategies? Reveal the worlds one at a time below. Early on, the running averages fly apart — one strategy looks like a genius, another like a fool. But keep revealing. As every hiding place gets its turn, the averages march back together until they land on the exact same number.

No free lunch

The No-Free-Lunch board

A prize hides in one cell. Each “world” is a different hiding place — and we visit every one. A strategy’s cost is how many cells it opens before finding the prize. Reveal worlds one by one and watch each strategy’s running average.

Where the prize is hidden

World 1
World 2
World 3
World 4
World 5
World 6

Press “Reveal next world”. Watch the averages start far apart — then collapse together.

Average stepsThis world
  • Left → right

    Always open cells in order, from the first to the last.

  • Right → left

    The mirror image — start at the last cell and work back.

  • Edges → middle

    Check the outer cells first, close in on the centre last.

  • Clever hunch

    A “smart”, hand-tuned order that just looks cannier than the rest.

Six cells, six worlds (the prize sits in each cell once). Four fixed search orders — including one hand-tuned to look 'clever.' Reveal the worlds and watch every running average converge to 3.5. Best-on-some is always worst-on-others.

Did you catch the drama? After the first world or two, the gap between best and worst strategy is huge — it really looks like the “clever hunch” or “edges-in” order is winning. That early lead is an illusion of a small sample. By the time all six worlds are in, all four strategies sit at exactly 3.5 steps. The clever order and the plodding one are worth precisely the same.

Warning:

The trap of the early lead

A strategy that looks great after a handful of problems hasn’t found a free lunch — it’s just been handed the problems it happens to suit. Judge a method on the full spread of problems it’ll face, not the flattering first few. Small samples are where free-lunch illusions are born.

On the board, why do the running averages start far apart and then converge?

Why this doesn’t depend on the example

You might worry this is a trick of treasure hunts. It isn’t. The same bookkeeping runs whenever you (a) consider all possible problems with equal weight and (b) score each method on each. Every method that’s good at some problems is, by that very fact, using up its goodness there and leaving other problems under-served. There’s a fixed budget of “good performance” to spread across all problems, and no method gets to have more of it than another. The treasure hunt just makes the budget visible.

Match each piece of the argument to what it does.

Pick a term, then click its definition.

Recap

Big picture

Why the tie is forced

  • Why No Free Lunch is true
    • Count every problem equally
      • No favourites among hiding places
    • Each strategy: same cost-total
      • Its costs are just a reshuffle
    • Wins here = losses there
      • They cancel perfectly
    • So: identical averages
      • Early leads are small-sample noise

We’ve now seen the tie is real and forced — not a failure to find the clever strategy, but a mathematical certainty. Which raises the obvious, urgent question: if every method ties, why does anything work at all in real life? The next lesson resolves that — and it’s where most people misread the theorem badly.

Mark lesson as complete