You have six guesses to figure out a 3 digit code. After each guess, you will be told exactly how many digits are correct but in the wrong place and how many digits are correct and in the right place. You have made these five guesses already:

- 865: exactly one digit in the right place
- 964: exactly one correct digit but in the wrong place
- 983: no correct digits
- 548: exactly two correct digits but in the wrong places
- 812: exactly one correct digit but in the wrong place

What is the correct 3 digit code?

#### Solution

425

548 has two correct digits but in the wrong places. But 8 is not one of those digits, since 983 has no correct digits. So two of the digits must be 4 and 5.

865 has one digit in the right place. It can’t be 6, since 964 has a 6 in the same place and you are told 964 only has a digit in the wrong place. It can’t be 8, since 983 has no correct digits. So the last digit must be 5.

964 has one correct digit but in the wrong place. We know 4 is one of the correct digits and it is not the middle digit, so 4 must be the first digit.

812 has one correct digit but in the wrong place. It can’t be 8, since 983 has no correct digits. It can’t be 1 because the correct digit is in wrong place and we’re only missing the middle digit. So the middle digit must be 2, giving us 425.

425…

425

425