Code Crack — The Mastermind Method
Code Crack is provably solvable in five guesses or fewer. Here is the optimal first guess, the deduction procedure, and the single mistake most players make repeatedly.
Code Crack (#11) is a Mastermind variant: guess a four-colour secret code from six possible colours, and each guess returns feedback about how many colours are correct in the right position and how many are correct but in the wrong position. Most players treat it as trial and error. It is not. There is a known optimal first guess, a deterministic decision procedure that guarantees a solution in at most five attempts, and a small set of techniques that close the gap between "I usually solve it in seven" and "I always solve it in five or fewer".
The optimal first guess
Donald Knuth proved in 1976 that the original Mastermind game is solvable in five guesses or fewer with perfect play. The first guess in his algorithm is two pairs of different colours — for example, red-red-green-green. This is not the most informative single guess, but it is the one that minimises the worst-case number of guesses needed afterward. Code Crack uses the same six-colour, four-position structure as classic Mastermind, so Knuth's result applies directly. Open every game with two pairs of different colours.
Beginners often guess four different colours on move one ("to find out which colours are in the code"). This feels intuitive but is mathematically worse: it gives slightly less reliable information about repeats and leaves a larger candidate space after the feedback. The two-pairs opening is genuinely better, even though it looks redundant.
What the feedback actually tells you
Code Crack returns two numbers after each guess: black pegs (correct colour, correct position) and white pegs (correct colour, wrong position). The total of black plus white is the number of correct colours in the code, regardless of position. Most players read these correctly. What they often miss is the negative information: if black plus white is two, then two of your guessed colours are not in the code at all. That is half the information in the feedback, and it is the half that lets you eliminate possibilities quickly.
After a two-pairs opening (say red-red-green-green), the feedback is immediately informative: if you get two pegs total, exactly one of red or green is in the code; if you get four pegs total, both colours are in the code in some quantity; if you get zero, neither is. This eliminates two of six colours in a single move. Compare to guessing four different colours, which only tells you how many of those four are present without distinguishing which.
The deduction phase
Once you know which colours are in the code (usually after two well-chosen guesses), the remaining problem is positional. This is where the second technique matters: minimal-difference guesses. Instead of guessing four colours at once, change only one or two positions from your previous guess and see whether the peg count changes. If you swap red in position one for blue in position one, and the black peg count goes up by one, red is not in position one and blue is. If the count goes down, the opposite. If the count is unchanged, neither belongs in position one (or both do, which the white pegs will distinguish).
This sounds slow but in practice resolves the entire positional problem in two or three guesses once the colour identification is done. The total game is then: two guesses to identify colours, two or three guesses to position them — under five, comfortably.
The mistake to stop making
The single biggest mistake in Code Crack is guessing colours you have already proven are not in the code. Players do this surprisingly often, usually because they forget the previous feedback. Keep a mental (or paper) note of which colours are eliminated after each guess. Five minutes of disciplined note-keeping converts a seven-guess average into a four-guess average. The game is genuinely solvable; what is hard is solving it consistently, and that comes from refusing to waste guesses on already-eliminated information.
Published · 14 May 2026 · Written and signed by Bill