
My strategy to get to the correct answer in as few a tries
as possible is as follows:
This is what I know at
the start: there are 6 colours, they may be duplicated.
I start by trying a set
of the first 4 colours - red, orange, yellow, green.
From the score for the
first attempt I know that I have two of the correct colours, but only one is in
the correct position.
On the next attempt to
find the secret code I use the other two colours (blue and purple) duplicated.
From the score for this
attempt (attempt #2) I know that the remaining two colours are either both blue,
both purple, or one blue, one purple.
On the next attempt
(attempt #3) I try a red and a green, putting the red in the same position as
in attempt #1, and trying green in a different position than in attempt #1 -
thus being a possible combination for the score of attempt #1. At the same time
I put two blues in the remaining positions being one possible solution for the
score of attempt #2.
The score of attempt #3
tells me a number of things:
Two blues are not in the
secret code, otherwise there would have been a 2 score for correct position.
From attempt #2 we know that blue does not occupy the first two positions.
There are not two blues in the secret code. This means there may be two purples
- or one blue, one purple. If blue is in the code, it must be in one of the
last two positions. I assume that the code has one blue and one purple - since
two blues is not correct and one blue and one purple is more probable than two
purples. If blue is in the code, then either red OR green is in the code, because
the score of attempt#3 only allows for one more colour if the other colour is
blue.
In attempt # 4, I place purple and blue in possible
positions for their colour, and use two possible colours and positions for the
other two positions.
The score of 2 0 for
attempt #4 means that if blue and purple are two of the colours in the code,
and at least one of these must be, then the other two colours red and orange
are not in the code - meaning (from attempt #1) that yellow and green are in
the code. I'm assuming that the correct colour in the third position is blue,
which means that the green cannot be in position two otherwise there would be a
2 0 score for attempt # 3. So I guess the correct combination for attempt #5.
Those of you who like
math, think about how simultaneous equations map to this type of game.