Maison BeaulieuMAISON BEAULIEUAB ÉDITIONS · CULINARY ARTS & ARCHIVES
Art of Living · Parlour Games

In Mastermind, Can an Impossible Guess Be the Best Question?

Only four possible codes remain. The instinct would be to pick one of them, since it could win immediately. Yet another guess, already ruled out as the answer, can separate those four possibilities more effectively. To understand that choice, we must look at what a response would leave intact, and then count the turns needed to actually finish the round.

We will follow two constructed and calculated situations. They do not come from an observed game. The digits represent colours: 1122 means two occurrences of the first colour, followed by two occurrences of the second. It is not the number one thousand one hundred and twenty-two.

🎁 Free Heritage Gift · A4 Illustrated Booklet + 5 MP3s

Receive the “Pantheon of 28 Legendary Chefs” Dossier (Free A4 PDF) + 5 Audio Stories

Instant complimentary access to our illustrated gastronomic & historical dossier, plus 5 DRM-free MP3 audio chronicles.

Fixing the rule before counting

Donald Knuth’s model has four positions and six available colours, with repetitions allowed. Feedback counts exact positions first, then correct colours in the wrong positions, without reusing any occurrence.

This framework does not describe every boxed edition indiscriminately. The Hasbro 44220 instruction sheet presents eight colours, a standard rule with four distinct colours, and an advanced variant allowing repetitions.

Take the secret 1134 and the guess 1111. The first two positions match. They use up the two occurrences of 1 available in the secret. The other two 1s in the guess can no longer be paired: the feedback is therefore (2,0). A method that only asked whether each 1 appears somewhere would find four positive answers. Yet it would be making two hidden copies do the work of four.

Now shift the same quantities of colours into the guess 3411. No position matches, but every occurrence finds its counterpart: the feedback becomes (0,4). The first count was not about two colours present and two colours absent. It was about copies, whose count and position act separately. This distinction makes it possible to read the following responses without granting a single colour an unlimited number of matches.

A response that leaves exactly four codes

We now guess 1122 and receive (2,2). In total, four occurrences match. The secret therefore cannot use a third colour: it would find no copy in the guess. It must also contain exactly two 1s and two 2s. With three 1s, for instance, only two would find a partner, and only one 2 would remain for the fourth required match.

There are six arrangements of two 1s and two 2s. We can write them all out: 1122, 1212, 1221, 2112, 2121, and 2211. The first would produce four exact positions. The last would produce none. They do not fit the feedback received. Each of the other four yields two exact positions and two misplaced matches. Our set is therefore exactly:

1212   1221   2112   2121

The completeness of this list does not come from its brevity. We first constrained the counts of each symbol, then checked all of their arrangements. Without that first step, four neat guesses on paper might simply be four ideas among others. Here, we also know why no code containing 3, 4, 5, or 6 has been overlooked.

Let us try 1212, the first candidate. If the secret is 1212, we win. If the secret is 2121, the feedback (0,4) singles it out alone. Yet 1221 and 2112 both produce (2,2). That third outcome preserves an ambiguity. It shows why the quality of a question is not measured solely by its ability to be the right answer in a favourable case.

Let us look more closely at the branch where 1212 receives (2,2). With the secret 1221, the exact matches lie in the first and second positions. With 2112, they lie in the third and fourth. Both secrets nonetheless produce the same feedback. It guarantees a total of two, without naming which positions are involved. Our earlier example 1134 let us see the secret to check the count; here, that is precisely what we still do not know.

Keeping the first two pegs of 1212 as settled would eliminate 2112, even though it remains compatible with both observations. Keeping the last two would conversely eliminate 1221. None of the four positions even shares a common value across the two remaining secrets: they differ everywhere. The number of correct places is known, yet no individual place is known. This check prevents turning the two feedback pegs into two specific pegs one could point to.

We ran the same check for each of the other three candidates. All of them partition the four secrets in the same way by group size: one winning case, one other singled out alone, and a group of two still confounded. Which codes form each group may change. The size of the largest group, however, stays two. No choice inside our list avoids that outcome.

Trying 1213 while knowing it is not the secret

The guess 1213 contains a 3. We already know it cannot win. Look, however, at the responses it would produce:

The four responses obtained
Still-possible secretFeedback for 1213
1212(3,0)
1221(2,1)
2112(1,2)
2121(0,3)

Each row receives a different feedback. Hearing that feedback is therefore enough to identify the secret. The third symbol is not there to guess a new colour: its known absence helps build a test. It occupies a position where we seek no match, while the other three positions separate the arrangements we care about.

We can verify why the total stays three across all four rows. The guess contains two 1s, one 2, and one 3. The first two types find three partners in every remaining secret; the last finds none. What varies is how those three matches split between exact and misplaced positions. Here, the number of well-placed pegs runs from zero to three, which is enough to yield four distinct responses.

Knuth already describes comparing partition sizes and using non-candidate guesses. The situations above are our calculated examples of that principle.

Two guaranteed turns do not mean an immediate win

Suppose 1213 receives (2,1). We can name 1221, but we have not played it yet. From our four-possibility state, the sequence therefore takes two turns: the test, then the identified code. The same count applies to the other three responses in the table.

After a candidate such as 1212, the (2,2) branch leaves 1221 and 2112 instead. If we next guess 1221 and it is not the secret, we still have to play 2112. That makes three turns, counting the first. Starting with 2112 in that final hesitation merely reverses which case is unfavourable.

There is no cleverer guess missing that would automatically win in one move against both of those secrets. A single line cannot equal two distinct codes. A branch of two thus forces at least two turns in the worst case from that point. Testing them one after the other meets that bound. We therefore have a complete local proof: any candidate played first can require three turns, whereas 1213 guarantees two.

The average also depends on the assumption about the secrets

That guarantee has a price: it gives up winning on the very first turn. Let us start with 1212 and reserve 1221 as our first choice in the tie. In the order 1212, 1221, 2112, and 2121, this path takes one, two, three, and two turns respectively. If all four secrets are assumed equally likely, the average is (1 + 2 + 3 + 2) / 4, or two. With 1213, we finish in two in all four cases. The averages are equal, whereas the guarantees differ.

Now add a different calculation assumption: given the information already received, we assign 1212 a probability of seven-tenths, and one-tenth to each of the other three secrets. These probabilities are chosen for this example. The feedback (2,2) did not reveal them, and we do not claim to have measured a player’s habits. The set of compatible secrets remains exactly the same; we change only the weights used to evaluate the paths.

With those weights, the average for the path starting with 1212 becomes (7 × 1 + 1 × 2 + 1 × 3 + 1 × 2) / 10, or 1.4 turns. The first term weighs heavily because the secret assigned a seven-in-ten chance costs a single turn along this path. With 1213, all four costs stay at two: the average remains two, regardless of how each row is weighted. This path therefore gains an average advantage under the extra assumption explicitly chosen.

The worst case, however, has not budged. All four secrets keep a positive probability; the path starting with 1212 can still take three turns, versus two for 1213. Wanting to avoid a third turn at all costs and wanting to lower the average under these weights lead here to different decisions. Saying that the first secret is “likely” is not enough: the calculation uses a specific weighting, whose justification must be open to discussion. Without that assumption, we return to the uniform comparison, where both averages were equal.

Another situation genuinely separates two criteria

Let us change the initial response. After 1122, we receive (0,2) this time. Calculating across all codes leaves 96 possibilities. For this set, we compared the groups created by each of the 1,296 allowed guesses. Two criteria yield different choices.

The first seeks to make the largest group that could remain as small as possible. The second seeks to minimise the average number of remaining possibilities, assuming each of the 96 secrets is equally likely. Here are the calculated results:

Comparing two guesses
GuessLargest remaining groupAverage remaining count
2344181,278 / 96 = 13.3125
2314221,218 / 96 = 12.6875

The first row protects better against an unfavourable response. The second gives a lower average, while accepting a response that leaves 22 possibilities. These are not merely two guesses picked at random. In the exhaustive comparison, no guess lowers the maximum below 18. Among those that achieve 18, the smallest sum used for the average is 1,278. Across all guesses, the smallest sum is 1,218, and those that achieve it cannot bring their maximum below 22. No choice therefore achieves both optima simultaneously.

Computing the average calls for a specific precaution. The possible responses are not equally likely. A group of 22 secrets will be reached for 22 of the 96 secrets, whereas a group of one secret will be reached for only one. Each size must be weighted by the number of secrets that produce it. The group of 22 thus contributes 22 times 22 to the numerator, not a single contribution of 22. The sum of the squares of the group sizes, divided by 96, gives the stated average count.

Merely counting the number of distinct responses does not perform that operation. A question may offer several tiny classes and one very large one; the number of filled cells in its table does not say how often we will encounter each. Choosing a criterion therefore translates into a way of reading the entire distribution, rather than a general preference for guesses that look varied.

Choosing what you want to optimise

Both of our averages concern the remaining count after a single response. They do not give the average number of turns needed to win afterward. With 2314, the winning response even forms a group of one secret: that count of one requires no further turn at all. To compare complete strategies, one would have to take future moves and responses into account, not just the size left right now.

The work of Kenji Koyama and Tony Lai precisely distinguishes a global optimisation on average from a variant capped at five turns in the worst case. Our local calculations do not replicate their global search. They show, at a scale we can inspect by hand, why naming a game and asking for “the best guess” still leaves a question open: best according to which guarantee and which average?

For our first situation, the answer is clear-cut: a guess impossible as the secret can guarantee a shorter finish than any candidate. For the second, two local criteria come into conflict. Neither result requires playing by computing all 1,296 lines on every turn. They offer a sharper way to understand a surprising move: a guess can serve to win, to split possibilities, or to cap risk, and those functions do not always coincide.

Method of calculation and reading

The examples were computed programmatically, then verified independently. All 1,679,616 pairs of codes were checked using two ways of counting occurrences, followed by a third independent check. The optimisations cover the next response, with no human games or physical board trials. As for the sources: two plates of the Hasbro instruction sheet were examined; pages 1, 2, 3, and 6 of Knuth’s paper were read visually, without reproducing the tree on pages 4–5; the reading of Koyama and Lai covers the introduction, the definition of candidates, and the presentation of results in their manuscript hosted by the co-author.