Keep only codes that fit every test

Treat each test as a check every possible code must pass, and change one thing at a time

A test is a check, not a clue to one digit

Test 11230 exact · 2 elsewhere
Two of 1, 2 and 3 are in the code, neither in the place tested.

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.

More

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.

Lesson help

A code stays possible only while it gives the same counts as every test you have run.

About this lesson

Try the method in a practice when you are ready.

Report

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.

Test 11230 exact · 2 elsewhere
Two of 1, 2 and 3 are in the code, neither in the place tested.

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.

Test 11230 exact · 2 elsewhereTest 21241 exact · 1 elsewhere
Only the last digit changed between the two tests.

Check a code against the history

A new puzzle: three digits from 1 to 5, no repeats. Try each choice against both tests.

Test 11230 exact · 2 elsewhereTest 22141 exact · 1 elsewhere
Two tests so far.

Try it

Which code fits both tests?

  1. 3 1 5
  2. 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

Sign in free

Practice without limits and keep your progress.