TUTORIAL ON MASTERMIND CODEBREAKING STRATEGY (5)
(DIGITS / COLOURS MAY BE REPEATED)

Readers are advised to read "Tutorial on Mastermind Codebreaking Strategy (1)" before reading this webpage so that he / she may have a general understanding of the basic principles of Mastermind Codebreaking.

Game Setting: No. of colours: 7; Start from: Trial 1; Length of code: 5; Hints contain error(s)?: No error; Order type: Fixed order; Colour repeated?: Each colour at most 4 times

Code: 23336


Under this game setting, the game becomes quite complicated because not only do we have to consider what digits are included in the Code, but we also have to consider the number of times such digits may be repeated. Moreover, as there is no way for us to distinguish the same digit that appears in different positions of the Code, sometimes it is difficult to determine which digits are to be the "New Digits Used in this Round". For instance, suppose we use 3 0s in the 1st Round and 5 0s in the 2nd Round. Then which 0s are new digits in the 2nd Round, and which are old? As a solution to this problem, I adopt a "conservative principle", i.e. I treat the digits used in the process of making guesses as old digits wherever possible. Under this principle, among the 5 0s used in the 2nd Round, I will treat 3 of them as old digits and the remaining 2 as new digits. Now let me illustrate this strategy with the following example.

In the beginning we may input any 5 digits. But now we have a problem: shall we include any repeated digits in our input? If so, how many times should each digit be repeated? There is no standard answer to this question and it is a matter of personal preference. I have chosen 00012 as the input for the 1st Round. Having input the guess, the hint I get is 1. Thus at the end of the 1st Round, we get the following Trace Table:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
100012100012-

Then we enter the 2nd Round and we review the guess result in the 1st Round first. As we get 1 correct digit in the 1st Round, we assume this digit is 0. In addition, we need 4 new digits, 3345 for instance. After inputting 03345, the hint we get is 2. Thus at the end of the 2nd Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000120
20334523345-

Then we enter the 3rd Round and we review the guess result in the 2nd Round first. As we get one more correct digit than we did in the 1st Round, we may assume the correct digit as 3. As we now assume that 03 is correct, we still need 3 new digits. But now we are only left with 6 and under the present game setting, each digit may be repeated 4 times, so we may input 03666 in the 3rd Round. The hint we get is 2. Thus at the end of the 3rd Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000120
203345233453
3036662666-

Then we enter the 4th Round and review our guess result in the 3rd Round first. As we assumed in the 3rd Round that 03 was correct and the hint we got was exactly 2, it is probable that 03 is correct. But if 03 is really correct, then according to the guess results from the 1st to the 3rd Rounds, we can infer that 1, 2, 4, 5, 6 must not be included in the Code. Moreover, although our guess in the 1st Round contains 3 0s, there is only 1 correct digit in that Round. This shows that the Code can only contain 1 0 and so 0 cannot be repeated. Similarly, although our guess in the 2nd Round contains 1 0 and 2 3s, there are only 2 correct digits. This shows that the Code can only contain 1 3 and so 3 cannot be repeated either. Therefore 03 cannot be combined with any digits to make up the Code. This shows that our previous assumptions must be incorrect and so we must go back to modify our previous assumptions. We first return to the 2nd Round and change the assumption to 4. And then we proceed forward to the 3rd Round again. Comparing 04 and 03666, we conclude that if the Code really contains 04, then we should get at least 1 correct digit in the 3rd Round. The hint for that Round is 2, which is one more than what we expected and so that digit must be 6.

As we now assume that 046 is correct, we are still short by two digits. But now there is no new digit for us to use. Does it mean that our assumptions are still incorrect? But wait a minute. Don't forget that under this game setting, the digits may be repeated. Now let's analyse which digits may be repeated and which may not. According to the guess results from the 1st to the 3rd Rounds, we may infer that if 046 is correct, then 1, 2, 3, 5 must not be included in the Code. Moreover, as we get only 1 correct digit in the 1st Round, the Code can only contain 1 0 and so 0 cannot be repeated. Similarly, as we get only 2 correct digits in the 3rd Round, the Code can only contain 1 6 and so 6 cannot be repeated either. So far we have determined that 0, 1, 2, 3, 5, 6 are either not included in the Code or not repeatable. We are still left with 4. Can 4 be repeated? The answer is yes, because in the 2nd Round we only guessed that the Code contains 1 4. This does not rule out the possibility that the Code contains more than 1 4. In fact, if we use 04446 as our guess for the 4th Round, this combination does not contradict our guess results from the 1st to the 3rd Rounds (the readers are asked to verify this). Thus we input 04446 in the 4th Round and the hint we get is 1. Thus at the end of the 4th Round, our Trace Table becomes (please note that in the 4th Round we only treat 2 4s as new digits because in the 2nd Round we used 1 4 and now in the 4th Round we use 3 4s. We have treated one of the 4s as old digit and so there are only 2 new digits in that Round):

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000120
203345233454
30366626666
404446144-

Then we enter the 5th Round and review our guess results in the 4th Round first. As we assumed in the 4th Round that the 046 was correct and the hint we got was only 1, this shows that our assumptions were incorrect and so we must go back to modify our previous assumptions. If we return to the 2nd Round and change the assumption to 5, the problem still persists (the readers are asked to prove this), and so we must return to the 1st Round.

After changing the assumption in the 1st Round to 1, we proceed forward to the 2nd Round again. Comparing 1 and 03345, we conclude that if the Code really contains 1, then we should get no correct digit in the 2nd Round. But the hint for that Round is 2, which is two more than what we expected. We may assume these two digits as 33. Next we proceed onward to the 3rd Round. In this Round we assume that we get 1 6 correct (why?). Next we proceed onward to the 4th Round and find that the guess result for that Round does not contradict our assumption 1336. As we now assume 1336 is correct, we are still short by 1 digit. We now determine which digits can be repeated. According to the guess results from the 1st to the 4th Rounds, we can infer that 0, 2, 4, 5, 6 are either not included in the Code or not repeatable and we are left with 1 and 3, which are both repeatable (the readers are asked to verify this). I have chosen 1 and input 11336. As a result, I get the hint 3. Thus at the end of the 5th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000121
2033452334533
30366626666
404446144-
51133631-

Then we enter the 6th Round and review our guess result in the 5th Round first. As we assumed in the 5th Round that 1336 was correct and the hint we got was only 3, this shows that our assumptions were incorrect and so we must go back to modify our previous assumptions. We return to the 2nd Round and change our assumption to 34 and then proceed forward again. In the 3rd Round we assume that we get 1 6 correct (why?). But 1346 is contradictory to our guess result in the 4th Round. So we have to return to the 2nd Round, change the assumption to 35 and then proceed onward again. Same as before, we assume that we get 1 6 correct in the 3rd Round. This time our assumption 1356 passes the validation in the 4th and 5th Rounds. As we now assume that 1356 is correct, we are still short by one digit. We now determine which digits may be repeated. According to our guess results from the 1st to the 5th Rounds, we can infer that 0, 1, 2, 3, 4, 6 are either not included in the Code or not repeatable and we are left with 5, which is repeatable the readers are asked to verify this). So we input 13556 and the hint we get is 2. Thus at the end of the 6th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000121
2033452334535
30366626666
404446144-
51133631-
61355625-

Then we enter the 7th Round and review our guess result in the 6th Round first. As we assumed in the 6th Round that 1356 was correct and the hint we got was only 2, this shows that our assumptions are incorrect, and so we must go back to modify our previous assumptions. We return to the 2nd Round, change the assumption to 45 and then proceed forward again. In the 3rd Round we assume that we get 2 6s correct (the readers are asked to verify why I make this assumption). But 14566 contradicts the guess result for the 4th Round and so we have to return to the 2nd Round once again. But the assumption 45 in the 2nd Round is already the last possible assumption and is thus unchangeable. So we are forced to return to the 1st Round.

In the 1st Round we change the assumption to 2 and then proceed forward again. In the 2nd and 3rd Rounds, we assume that 33 and 6 are correct, respectively (why?). This time our assumption 2336 passes the validation in the 4th to 6th Rounds. As we now assume that 2336 is correct, we are still short by one digit. We now determine which digits are repeatable. According to the guess results from the 1st to the 6th Rounds, we can infer that 0, 1, 4, 5, 6 are either not included in the Code or not repeatable. We are left with 2 and 3, which are both repeatable (the readers are asked to verify this). I have chosen 2. After inputting 22336, the hint I get is 4. Thus at the end of the 7th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000122
2033452334533
30366626666
404446144-
51133631-
61355625-
72233642-

Next we enter the 8th Round and review our guess result in the 7th Round first. As we assumed in the 7th Round that 2336 was correct and the hint we got was exactly 4, it is probable that our assumption is correct. But why is the Code still not broken? The reason may be that in the previous Round we incorrectly chose 2 as the digit to be repeated. So we now choose 3 alternatively and input 23336. This time we successfully break the Code (if the Code is still not broken, then there are two possibilities: either our previous assumptions are still incorrect and we have to go back to modify our previous assumptions, or the hints provided by the Codemaker contains error(s), which will be detected sooner or later). Thus at the end of the 8th Round, our Trace Table becomes:

RoundInputHintNew Digits Used in this RoundDigit(s) Assumed to be Correct
1000121000122
2033452334533
30366626666
404446144-
51133631-
61355625-
72233642-
823336WIN3-

Link to Mastermind Link Page.