
Yes. In standard four-peg, six-colour Mastermind, you can force a win within five guesses: Knuth’s published algorithm proves it for all 1,296 possible codes. The catch is that the method is a solver’s mastermind strategy, not the way most humans think over a cup of tea.
The popular mastermind five guesses claim is about the classic rules: repeats allowed, four positions, six colours, and feedback that reports exact matches and right-colour-wrong-place matches. Change those rules and the number changes. Add more colours, ban repeats, change the length, or give different clues, and you need a separate result.
The useful lesson is not that five is magic. It is that Mastermind becomes manageable when you stop asking, “What feels likely?” and start asking, “Which guess cuts the remaining possibilities hardest?” Knuth’s algorithm is famous because it turns that question into a repeatable rule.
Can you always win Mastermind in five guesses?
You can always win standard Mastermind in five guesses if you use a complete five-move decision method. The best-known one is Donald Knuth’s 1977 algorithm. It covers all 1,296 possible secret codes in the classic four-position, six-colour game with repeated colours allowed.
The claim has limits. It is not “any sensible player will solve it in five”. It is not “the first four guesses are fixed”. It is not “you only ever guess codes that could still be the answer”. Knuth’s method is a branching tree: each guess depends on the feedback from the previous guess, and some guesses are used because they split the possibilities well, even when they cannot themselves be the secret.
The usual opening in Knuth’s published method is 1122: two pegs of one colour and two pegs of another. On a lettered board, think AABB. From there, every possible feedback result points to a smaller set of codes. The algorithm then chooses a next guess that makes the worst remaining pile as small as possible.
For normal play, five guesses is therefore a ceiling, not a promise about your unaided instincts. A human player can often win well within ten guesses with disciplined elimination, but can also drift badly by chasing attractive-looking answers. The five-guess result belongs to a precise solver rule applied without mistakes.
What figure should a player trust, and where does it come from?
Trust the worst-case number first: five guesses. It is the figure that answers winnability. Averages are interesting, but an average can hide a few stubborn codes that take longer.
- 1,296 codes: this is arithmetic, not a study. Four positions, six choices each, repeats allowed: 6 × 6 × 6 × 6 = 1,296.
- Five guesses: this is the published Knuth algorithm result for standard Mastermind. It gives a strategy that solves every one of those 1,296 codes in no more than five guesses.
- About 4.478 guesses: this is a solver result for Knuth’s minimax rule over the full standard code set. Treat it as the average for that algorithm, not as the best possible average.
- 5,625 / 1,296, about 4.340 guesses: this is a published optimal-average result by Koyama and Lai for standard Mastermind. It improves the average, while the five-guess ceiling remains the clean winnability answer.
No estimate is needed for the main claim. The code count is exact, and the five-guess guarantee is a published result for a fixed rule set. If a page gives a different number without stating the rules, it is probably mixing variants.
Which one mechanic makes the game hard enough to need a plan?
The hard mechanic is anonymous feedback. Mastermind does not tell you which peg was right. It only tells you how many pegs are exact matches and how many are correct colours in the wrong positions.
Suppose you guess AABB and receive one exact match and one misplaced match. You know that two parts of your guess have hit something useful. You do not know whether the exact match was the first A, the second A, the first B, or the second B. You also do not know which colour caused the misplaced match. Duplicates make that uncertainty worse, because the same colour can be involved more than once.
For four pegs, there are 14 possible feedback scores. That sounds generous until you remember there are 1,296 possible hidden codes before the first guess. Each clue is therefore a sorting signal. It throws every possible code into a bucket according to the answer it would have produced.
This is the single reason the Knuth algorithm works. It does not guess by resemblance to the secret. It guesses by partitioning. A strong guess is one that prevents any feedback result from leaving a large, awkward bucket behind. Weak guesses may look plausible, but they let too many possible secrets survive together.
What does a solid Mastermind strategy actually look like?
- Start with a structured split. AABB is a good human-friendly opening, and it matches the shape of Knuth’s 1122 start. You learn about two colours at once and you get information about duplicates.
- Write down what survives. After each clue, keep only the codes that would have produced exactly that same feedback against your guess. If a code would have given a different clue, it is impossible. Cross it out mentally or on paper.
- Judge a guess by its worst case. For each possible next guess, imagine scoring it against every code still alive. Group those codes by feedback result. The largest group is the danger: if you get that clue, all those codes remain.
- Prefer the guess with the smallest largest group. This is the core minimax idea behind the Knuth algorithm. A guess can be valuable even if it cannot be the answer, because it may cut the remaining set more evenly than any candidate answer would.
- Only chase the answer when the list is small. Early in the game, information beats hope. Later, when two or three codes remain, direct guessing is fine because every clue almost settles the matter.
- Respect duplicate colours. Many errors come from treating one white peg as proof that a colour appears once. It proves a match of that type, not the full count unless the rest of the clue forces it.
How does Mastermind compare with Bulls and Cows, and why do people mention the Knuth algorithm?
Mastermind and Bulls and Cows are close cousins: both reward elimination, and both punish lazy reading of feedback. The exact five-guess number belongs to standard Mastermind, so do not transfer it without checking the rules.
| Question | Mastermind | Bulls and Cows | Why it matters |
|---|---|---|---|
| What is hidden? | Four positions chosen from six colours, with repeats allowed in the standard result. | Usually a sequence of digits; the exact code space depends on the chosen rule set. | The size of the search space controls how strong the guarantee can be. |
| What does feedback mean? | Exact colour and position, plus correct colour in the wrong position. | Bulls are exact hits; cows are right symbols in wrong positions. | The logic is similar enough that the same elimination habit carries across. |
| Is the feedback anonymous? | Yes. It gives counts, not peg identities. | Yes. It gives counts, not digit identities. | This is why both games need disciplined deduction rather than simple matching. |
| What trusted win claim applies? | Knuth’s published algorithm solves all 1,296 standard codes within five guesses. | The Mastermind five-guess claim does not automatically apply. | A figure is only useful when it matches the exact rules being played. |
| Why mention Knuth? | His algorithm is the classic example of minimax search in this game. | Players often borrow the same search-space thinking. | The name points to a method: reduce the worst remaining case. |
People mention the Knuth algorithm because it is clear, finite, and a little rude to intuition. It sometimes chooses a guess that cannot be right, purely because the answer to that guess will be more useful than a plausible-looking candidate.
Frequently asked questions
Yes. Veena Games uses four pegs chosen from six colours, with repeated colours allowed. That gives 1,296 possible secret codes. You get ten guesses, and each peg is lettered as well as coloured, so the game is playable even when colour alone is a poor clue.
1,296 codes are possible because each of the four positions can be any one of six colours. The first peg has six choices, the second has six, and so on: 6 × 6 × 6 × 6. Repetition is allowed, so AAAA and ABCA are both legal.
The common misconception is that each clue peg points back to a particular slot. It does not. A black clue means one peg is exactly right somewhere; a white clue means one colour is present but in the wrong place somewhere. The clue is a total for the whole row, not a map of the row.
On a board where the secret is AABC and the guess is ABCA, the feedback is one exact match and three colour-only matches. That single clue rules out every possible code that would not give exactly that result to ABCA. Good play is less about liking ABCA and more about keeping only codes consistent with it.
It depends on your aim: if you are playing casually, the first guess mainly gives you a first cut through the 1,296 codes. If you are trying to force the five-guess guarantee, the opening belongs to a full method. A strong start helps, but it is the follow-up filtering that does most of the work.
Compared with Bulls and Cows, Mastermind gives a similar exact-and-misplaced clue, but the feel changes because the code is made from colours and repeats are legal. Repeats are where many players lose track. Bulls and Cows trains the same habit: do not guess what looks plausible, guess what best separates the remaining possibilities.
Keep what the clue proves; the exception is when you need a test guess to separate several surviving codes. A row with three hits tells you the set is promising, but not necessarily the order. Sometimes the right next move uses a colour you think is absent because it gives cleaner information about positions.
Most people do wrong by treating a clue as confirmation too early. They see two hits, decide two particular pegs must be right, and build around that guess. If those two hits belonged to different pegs, the next three rows can become noise. Write down what the clue allows, not what you hoped it meant.
A candidate code is any secret code that still fits every clue you have received so far. After one guess, there may be hundreds. After several disciplined guesses, the list should shrink sharply. If a possible answer would have produced different feedback on any previous row, it is not a candidate any more.
Compare the new clue against every code you still think could be the answer. Remove any code that would not have given that exact feedback. Then choose a next guess that splits the remaining set well, even if it is not your favourite possible answer. This habit matters more than memorising a magic opening.
Nobody knows precisely; there is no reliable public figure for how often casual players win standard Mastermind in five guesses without following an algorithm. The best solid number is the mathematical ceiling: with the right method, the standard four-peg, six-colour game can always be solved within five guesses.
Donald Knuth published The Computer as Master Mind in the 1970s, and it gave a clear algorithmic answer to the standard game. His result is why five guesses became the famous benchmark. Players still mention it because it turns a parlour puzzle into a precise problem about information and worst cases.
The cost is a wasted branch: you spend guesses testing a story that the clues never proved. In Mastermind, one false assumption can leave you choosing between several live codes on the last row. Use each clue as a constraint, not as a hunch, and the board becomes much less slippery.
Final thoughts
The uncomfortable move in Mastermind is the one that feels least like guessing. You may have two tempting candidate codes sitting there, both neat, both possible, and the best move may be a third code you already know cannot win. That is where the game becomes interesting.
If you are playing by feel, you will tend to ask whether a code looks close. A solver asks what the reply will do to the whole remaining set. That question is colder, but it is also kinder: it stops you wasting three turns learning the same fact in slightly different ways.
For a human player, you do not need to run Knuth’s full tree in your head. Keep one habit. After every clue, ask which possibilities would have given exactly that clue. If the answer is “I am not sure”, slow down. Most Mastermind mistakes are not bold risks; they are bookkeeping errors.
Five guesses is a lovely benchmark, but ten guesses gives room to think. Use the room. Make a boring information move when the board asks for it. The satisfying win is often the one where the last peg feels inevitable before you place it.


