🕵️ Mastermind strategy: crack it in 5
By Miguel Arechaga
Mastermind is pure deductive reasoning: there is a secret colour code and you must uncover it in as few guesses as possible, guided only by the feedback. With the right method, almost any code falls in 5 guesses or fewer. Here is the method.
First: understand the feedback completely
After each guess you receive two kinds of clue:
- Black peg (or red, depending on the set): one of your colours is in the code and in the right position. It does not say which one.
- White peg: one of your colours is in the code but in a different position.
A key detail many miss: the pegs are not ordered. The first black peg does not refer to your first slot; only the quantities matter.
The ideal first guess
Open with two pairs of colours: for example blue-blue-red-red. Why? Because the reply instantly tells you how many blues and reds the code contains, far cleaner information than trying four different colours. On your second guess try two other pairs (green-green-yellow-yellow) and within two moves you will know almost the full colour composition of the code.
The elimination method
From the third guess on, every play must obey one sacred rule: be consistent with ALL previous feedback. Before placing, check: “if the code were what I am about to play, would the earlier replies have been exactly what they were?”. If any does not match, that combination is impossible: discard it and try another. This simple habit is 80% of the strategy.
Advanced tips
- Sacrifice a guess for information: sometimes it pays to play a combination you know is wrong but that separates two tied hypotheses.
- Count total colours: add blacks + whites of each guess: that is the number of correct colours (well or badly placed). Keeping that count kills impossible theories early.
- Watch for repeats: codes may repeat a colour. If your numbers “don't add up”, there is almost surely a doubled colour.
Pairs at the start, strict elimination afterwards and your counts up to date: you will see 4-5 guesses become your usual average.