17

Mastermind is a well-known game. Here's a brief reminder of the rules:

  • There's a secret code consisting of a sequence of five colored circles (items). Colors may appear more than once.
  • Your job is to figure out the code. You do so by guessing a sequence of five colors and then getting feedback on your guess.
  • The feedback consists of a number of black and white markers:
    • Black: you receive a black peg for each item of the correct color in the correct place.
    • White: of the remaining items, you receive a white peg for each one of a correct color but in the wrong place.
  • You receive at most one peg per item of the correct secret code.
  • The order of the black and white pegs has no significance
  • Example: suppose the secret code is RGGGG. If you guess RRRRR, you will receive 1 black (for the first R) and 0 whites. If you guess GBBBB, you will get 1 white and 0 blacks.

In this puzzle, you have had a few guesses already and are ready to guess again. Can you determine the secret code?

Mastermind Game

Dr Xorile
  • 23,406
  • 3
  • 47
  • 125

2 Answers2

16

The secret code is:

RED - GREEN - YELLOW - PURPLE - PURPLE

Explanation: At first glance, my gut instinct (soon to be proved wrong) told me this must be impossible! After all:

If the two rightmost pegs have been swapped from guess#3 to guess#4 and we still have 3 black and 2 white markers, then they cannot both have been correct on guess#3 and still both be correct on guess#4 (contradiction).
Equally, they cannot both have been mis-positioned on guess#3 and still both be mis-positioned on guess#4 (since that would require 2 of the first 3 pegs to be mis-positioned also, but we only have 2 white markers, not 4).

However, then I realised I had completely overlooked the possibility that:

The two rightmost pegs are supposed to be identical, and so only one of the green and purple was correct and the other mis-positioned both times.

Which colour could this be? Well, we know from guess#3 and guess#4 that we have to have:

1 red, 1 yellow, 1 green and 2 purples in total (since all 5 markers are present, meaning we have all the right colours, just not all in the right positions yet...)

So:

The two rightmost pegs must be PURPLE, since all other colours are only represented once.

It now follows that the other three must be ordered as:

RED - GREEN - YELLOW... since on guess#3 and guess#4 two of the black markers must have been referring to the first three pegs, and could not have been referring to the purple in slot 2 (which should have been in slot 4 or 5, and was therefore represented by a white marker). Therefore the red must be in slot 1, the yellow must be in slot 3 and - by deduction - the green goes in slot 2.

Meaning the final solution is as outlined at the top.

Stiv
  • 140,467
  • 11
  • 495
  • 752
4

The answer is

Red Green Yellow Purple Purple

I don't know what to explain...

Omega Krypton
  • 21,640
  • 2
  • 25
  • 125