Data set: Locker code
Locker code
A locker opens with a 4-digit code. All four digits are different and the first digit is not 0. Six guesses were tried, and each was given the feedback shown.
| Guess | Feedback |
|---|---|
| 7148 | 1 correct digit in the correct place |
| 2054 | 1 correct digit in the wrong place |
| 9361 | 1 correct digit in the correct place; 1 correct digit in the wrong place |
| 3520 | 2 correct digits in the wrong place |
| 8697 | 1 correct digit in the correct place; 1 correct digit in the wrong place |
| 1052 | 1 correct digit in the correct place |
What is the sum of the digits of the code?
Type in the answer (TITA): no options.
Show answer & solution
Correct answer: 21
Solution: (1) 2054 says exactly one of 2, 0, 5, 4 is in the code. 3520 says two of 3, 5, 2, 0 are, so 3 is in the code plus exactly one of 5, 2, 0, and 4 is out. (2) 9361 needs two of 9, 3, 6, 1, so one of 9, 6, 1 (call it y). 8697 needs two of 8, 6, 9, 7. If y = 1, there's no room for two of those, so y is 9 or 6 and the 4th digit (z) is 8 or 7. (3) 7148: exactly one digit, in place, so z sits where 7148 has it (7 → 1st place, 8 → 4th place). 1 is out. (4) 1052: one digit in place, so the digit x from {5, 2, 0} is where 1052 has it: 0 → 2nd, 5 → 3rd, 2 → 4th. But 2054 says x is misplaced there: 0 would be 2nd and 5 would be 3rd in both guesses, a contradiction. So x = 2 in 4th place, which forces z = 7 in 1st place. (5) The code is 7 _ _ 2 with 3 and y in the middle. 9361 needs exactly one in place: 7362 gives two in place and 7632 gives none, so y = 9. 7932 gives none in place, but 7392 gives 3 in place and 9 misplaced ✓. 8697 then gives 9 in place and 7 misplaced ✓. Code = 7392 (a computer check of all 4,536 possible codes confirms it's the only one). 7 + 3 + 9 + 2 = 21.