Mastermind is a game of code-breaking for two players. One of the players is codemaker (Alice) and the other is codebreaker (Bob).
4x4 means that the player should guess the length-4 sequence made of four alphabets (say
RGBY). The hidden sequence may have duplicate letters, so there are \$4^4 = 256\$ possibilities in total.
At the start of the game, Alice sets up a hidden code, which Bob should guess correctly within a set number of turns. At each turn, Bob presents a guess, and Alice tells Bob how many of the positions are correct, and how many of the letters are correct but at a wrong position. For example, if the hidden code is
RRYG and Bob guessed
Code: R R Y G Guess: B R G Y Correct: R(2nd-2nd) Wrong position: Y(3rd-4th), G(4th-3rd)
Then Alice tells Bob the two counts
1, 2. (Note that the first
R in the code does not contribute to the counts because the second
R in the guess was already consumed as Correct.) Bob repeats the guess with different sequences, until the guess is identical to the code (getting
4, 0) or he runs out of turns.
The Dream World mastermind solver features four specific guesses so that the unique answer can be derived from their outcomes in all cases. The guesses are as follows:
1. R G G R 2. B B R R 3. Y Y G R 4. G B B Y
Given the outcomes of the four combinations above (four pairs of integers), output the unique hidden code.
You can assume the input is valid and the answer exists. You can choose to output any four distinct values (numbers/characters) in place of
Standard code-golf rules apply. The shortest code in bytes wins.
NB: Fetching the results from the linked website is a standard loophole, and therefore forbidden.
Each pair in the input represents
(correct, misplaced). Note that the answer can be one of the four predefined guesses (generating a
(4, 0) in the input).
(2, 0), (2, 0), (1, 0), (0, 0) => R R R R (2, 1), (1, 0), (1, 2), (1, 1) => G G Y R (0, 2), (0, 2), (0, 3), (1, 2) => G R Y B (2, 0), (0, 0), (2, 0), (0, 2) => Y G G G (1, 1), (4, 0), (1, 0), (1, 1) => B B R R