Q1.
A number lock has a 3-digit code. Find the code using the hints below. 265 — One digit is correct and well placed. 271 — One digit is correct but wrongly placed. 542 — Two digits are correct but wrongly placed. 036 — Nothing is correct. 064 — One digit is correct but wrongly placed.
Answer
The code is 415.
Work through the hints in the order that gives the most information first.
Step 1 — use the hint that rules things out.
"036 — nothing is correct" → the digits 0, 3 and 6 are not in the code at all.
"036 — nothing is correct" → the digits 0, 3 and 6 are not in the code at all.
Step 2 — hint 064. One digit is correct but wrongly placed.
0 and 6 are already ruled out, so the correct digit must be 4.
It is wrongly placed, and in 064 the 4 sits in position 3.
→ 4 is in the code, but not in position 3.
0 and 6 are already ruled out, so the correct digit must be 4.
It is wrongly placed, and in 064 the 4 sits in position 3.
→ 4 is in the code, but not in position 3.
Step 3 — hint 542. Two digits are correct but wrongly placed.
In 542: 5 is in position 1, 4 in position 2, 2 in position 3.
Since 4 is correct and wrongly placed here, 4 is not in position 2 either.
From Step 2, 4 is not in position 3.
→ 4 must be in position 1.
In 542: 5 is in position 1, 4 in position 2, 2 in position 3.
Since 4 is correct and wrongly placed here, 4 is not in position 2 either.
From Step 2, 4 is not in position 3.
→ 4 must be in position 1.
Step 4 — hint 265. One digit is correct and well placed.
6 is ruled out. So the correct digit is 2 (position 1) or 5 (position 3).
Position 1 already holds 4, so it cannot be 2.
→ 5 is correct and well placed, in position 3.
And since only one digit of 265 is correct, 2 is not in the code.
6 is ruled out. So the correct digit is 2 (position 1) or 5 (position 3).
Position 1 already holds 4, so it cannot be 2.
→ 5 is correct and well placed, in position 3.
And since only one digit of 265 is correct, 2 is not in the code.
Step 5 — back to 542. Two of 5, 4, 2 are correct.
2 is out, so the two correct digits are 5 and 4 — which we already have. Consistent.
2 is out, so the two correct digits are 5 and 4 — which we already have. Consistent.
Step 6 — hint 271. One digit is correct but wrongly placed.
2 is out, so the correct digit is 7 or 1.
The only position still empty is position 2. If the digit were 7, it would have to go in position 2 — but in 271 the 7 is in position 2, and the hint says wrongly placed. Contradiction.
→ the correct digit is 1, and it is not in position 3 (where 271 puts it). Position 3 is 5, so that fits.
→ 1 goes in position 2.
2 is out, so the correct digit is 7 or 1.
The only position still empty is position 2. If the digit were 7, it would have to go in position 2 — but in 271 the 7 is in position 2, and the hint says wrongly placed. Contradiction.
→ the correct digit is 1, and it is not in position 3 (where 271 puts it). Position 3 is 5, so that fits.
→ 1 goes in position 2.
The code is 4 1 5.
Now check it against all five hints.
| Hint | What the hint says | Check against 415 |
|---|---|---|
| 265 | One correct, well placed | ✔ only 5, and it is in position 3 in both |
| 271 | One correct, wrongly placed | ✔ only 1; shown in position 3, actually in position 2 |
| 542 | Two correct, wrongly placed | ✔ 5 and 4; 5 shown in position 1 (really 3), 4 shown in position 2 (really 1) |
| 036 | Nothing correct | ✔ none of 0, 3, 6 appears in 415 |
| 064 | One correct, wrongly placed | ✔ only 4; shown in position 3, actually in position 1 |
Why this puzzle belongs in this chapter: each hint is a statement supported by evidence, and the code is the one answer that fits every statement at once. Notice how much work the negative hint did — "036: nothing is correct" removed three of the ten digits in a single stroke. In reasoning, a fact that rules possibilities out is often worth more than one that adds something in.
Tip: two words carry the whole puzzle. "Well placed" means the right digit in the right position. "Wrongly placed" means the digit belongs in the code but somewhere else — and that is what let us decide, at Step 6, that 7 was impossible.