# Master Mind

A number of attempts have been made to break the secret code.

The dots next to the guesses give information about the correct answer. A black dot corresponds to a digit in the right position. A white dot corresponds to a digit that does belong in the secret code, but is not in the right position. For each attempt each digit will result in at most one dot, and similarly for each guess at most one dot corresponds to a given digit in the solution. Next to the puzzle is stated which digits are valid.

## Example

We will show by a small example how this information can help to discover the secret combination.
When looking at the two upper rows combined, one can notice that they contain six different digits, and that three of those digits are either in the right position or not in the right position but still in the secret code. Because all six digits are different, we don't even need to know with which digits those three dots correspond in order to establish that there certainly are no other digits than these six in the final answer.

Therefore the 5 at the bottom row can not be part of the solution, from which we can immediately derive that the two dots on the same row belong to the digits 2 and 4. Because the 4 is in the same position here as it is in the middle row, and did not get a black dot for that over there, the 2 on the bottom row has to be correct. The 4 is not on the left, not on the right, but does belong to the secret code, so it must be in the middle.

Now the only question remaining is what the first digit could be. That also we can now derive logically. On the first row there has to be a digit in the right position, but it is not the 2 and it is not the 3 either, so it has to be the 1.

## Background

Mastermind was originally only a board game, invented by Mordecai Meirowitz from Israel in 1970. In this game one player chooses a secret colour combination consisting of 4 pegs chosen from a collection of pegs in 6 different colours. The goal of the opponent is to find the secret combination in as few guesses as possible with a maximum of 12. After each guess the first player will reveal the information similar to what was explained above.

In 1977 Donald Knuth from the United States managed to compute a strategy with which it is always possible to guess the correct code in the original game within 5 guesses. A strategy with a maximum of 6 guesses required, but with an average number of only 4.340, was discovered in 1993 by Kenji Koyama and Tony W. Lai from Japan.

Puzzles in this genre.