Here is an altered mastermind puzzle which instead of colored pegs I used digits from 1 to 9 without any repetition. The picture below shows four guesses and their corresponding scores.The black pegs are for every correct digit and correct position and the white pegs are only for the correct digits and wrong position. Your mission is to break the code on the fifth guess and find what the hidden number is. Good luck. N.B. for those who are not familliar with mastermind game I suggest to visit this site: https://en.wikipedia.org/wiki/Mastermind_(board_game)
The code is:
Note: When I speak of a number being white or black, I mean that it is represented by a white or black peg respectively.
5 and 8 cannot be the black in row 4, otherwise there would be a black in row 2 or 3. So neither 5 or 8 are in the code, since there is no white in row 4.
Similarly, neither 1 nor 2 can be the black in row 1, since there would then be a black in row 2. So 6 must be the black in row 1, and the first digit of the code.
Now, 4 must be a white in row 2, because otherwise both 1 and 2 are whites, contradicting row 1. So 4 is also a white in row 3.
If 2 were the white in rows 1 and 2, 1 must not be in the code. So 3 would be in the code, but then we have 5 digits in the code - 6, 2, 3, 4 and the 7 or 9 from row 4. So 2 is not the white in row 1 or 2.
So 1 is the white in rows 1, 2 and 3. 1 cannot be the first digit in the code, since 6 is. By the positioning of the white 1 in rows 1, 2 and 3, the 1 can't be the second or third digit either. So 1 is the fourth digit.
Now, 9 can't be black in row 4, since it would be the fourth digit and we know 1 is the fourth digit. So the 7 is black in row 4, and the second digit of the code.
Then the 4 must be the third digit of the code, since we know it is white.
The solution is:
From 1,2: In 1 the black dot is not the 1 or 2.
From 1,3: The black dot in 1 is not the 5.
Therefore the code starts with 6.
From 3,4: The 5 is not the black dot in 4.
Therefore 5 is not in the code.
From 1:Only 1 or 2 is part of the solution.
From 2:Only 4 or 8 is part of the solution.
From 2 and 4: 8 is not the black dot in 4.
Therefore 8 is not in the code.
So 4 is in the code.
From 4:Only 7 or 9 is part of the solution.
So the solution contains: (6), (7 or 9), (4), (1 or 2)
From 3:1 is part of the solution.
From 1,2,3: 1 is the last digit of the code.
From 4: 7 is the second digit of the code.
So 4 is the third digit of the code, making the code: 6741