Zum Inhalt springen
tableroom

Magazine Tresorknacker 2 min read

The Five-Guess Code: How Donald Knuth Solved Mastermind

Did you know?

4,096 combinations and zero luck: how information theory cracked the iconic code-breaking duel.

A hidden four-digit combination, a palette of colours, and an opponent providing sparse feedback after every attempt: one black peg for the right colour in the right place, one white peg for the right colour in the wrong place. Mastermind has stood as a benchmark for deductive logic since the 1970s.

To casual players, it feels like an educated guessing game against a ticking clock. To mathematicians, it was an optimization challenge waiting to be cracked.

Donald Knuth's Five-Guess Proof

In 1977, computing pioneer Donald Knuth of Stanford University tackled the classic board. With four slots and six colours, exactly 1,296 combinations exist (scaling to 4,096 combinations with eight colours).

Knuth formulated a minimax algorithm that proved something remarkable: regardless of the secret code chosen, any standard game of Mastermind can be solved in at most five guesses with absolute certainty.

The breakthrough relies on a counterintuitive principle: you do not guess to hit the code. You guess specifically to minimize the maximum number of remaining possibilities in the worst-case response.

The Optimal Opening Move

Almost every beginner opens with four distinct colours (e.g., Red-Blue-Green-Yellow) hoping to test as much ground as possible.

Knuth proved this is mathematically inferior. The optimal opening guess is almost always a double pair (such as Red-Red-Blue-Blue or 1-1-2-2):

  • Testing four single colours gives noisy feedback when a single peg hits, leaving a wide cone of ambiguity.
  • Testing two pairs partitions the probability tree into tighter, more balanced sets. The raw information gain is provably superior.

Cracking the Vault

Mastery of Mastermind comes down to cold elimination. Each peg is a mathematical sieve. At our table Tresorknacker, plastic pegs make way for a heavy 1920s bank safe: spin the dials, read the tumblers, and crack the combination before time runs out.

More from the magazine

All magazine articles

Feedback & bug report

How do you like it?

Your message comes with the page you are on, the size of your window and the kind of browser you use. We need no name and no address.

tableroom · Notifications

Request release notifications

No spam. A short message whenever a new case, a new board game, or a new table goes live.

Unsubscribe anytime with one click. No data sharing, no account needed.