A test is a check, not a clue to one digit
Each test gives two counts. Exact counts digits that are right and in the right place. Elsewhere counts digits that are in the code but in another place. The counts never say which digits they mean.
So use each test as a check. A code is still possible only if, tried against every test in your history, it would give the same two counts. One test that disagrees rules it out.
Make your next test change one thing from an earlier one. If you swap a single digit and the counts move, that digit caused the change.
1Read each test as two counts.
2Keep a code only if it gives the same counts for every test.
3Change one digit at a time between tests.
Change one digit
Three digits from 1 to 5, no repeats. Test 2 changes only the last digit, 3 to 4.
Exact went from 0 to 1, and only the last place changed, so 4 is in the code, in the last place. The total, exact plus elsewhere, stayed at 2. Taking 3 out and putting 4 in kept the total, and 4 is in, so 3 is in too.
Test 1 had no exact matches, so 1 is not first and 2 is not second. Two codes now pass both tests: 2 3 4 and 3 1 4. One more test separates them.
Check a code against the history
A new puzzle: three digits from 1 to 5, no repeats. Try each choice against both tests.
Try it
Which code fits both tests?
- 3 1 5
- 5 1 2
Show the answer
5 1 2
Right. Against 1 2 3, the code 5 1 2 has 1 and 2 in other places: 0 exact, 2 elsewhere. Against 2 1 4 it has 1 in place and 2 elsewhere: 1 exact, 1 elsewhere. It passes both.
Enable JavaScript to answer interactively and save your place.
Practice Crack the code