What is the logic used to solve this problem?
The answer is
The first clue lines in the fact that the passcode consists of three digits, yet four attempts have been made, all with exactly one correct digit. That means that at least two of the attempts must share a digit at the same spot, since the fourth attempt must have gotten one of the same digits right. In the puzzle, there are four such occurrences, and at least one of them must be correct. Let us exhaust them:
Exhausting the possibilities:
Let's assume the 6's at the end of the first and third attempts are correct. Well, then the 8's at the front of the first and fourth attempts are wrong. Thusly, in the fourth attempt, the first and last digits are incorrect, meaning the middle digit must be correct. The middle digit is a 4, which is also true for the third attempt. However, in the third attempt, it has already been assumed that the single correct digit is the 6. Thus, making this assumption leads to a contradiction, and therefore it must be false.
Let's assume the 4's in the middle of the third and fourth attempts are correct. Then the 8's the first and fourth attempts are incorrect, and the 9 in the first attempt must also be incorrect, since it shares the middle spot with the 4 (which is assumed to be correct). By elimination, the 6 at the end of the first attempt must be correct, but that means the 6 at the end of the third attempt is also correct; but that leads to the contradiction of both the 6 and 4 in the third attempt being correct. Thusly, the fours are incorrect.
Let's assume the 8's at the front of the first and third attempts are correct. That means that neither a 3 or 6 at the end is correct. That means that, for the second and third attempt, only the first and middle digits have a chance at being correct. Since they do not share their middle digits, only one of them can be correct, and the other must lie in the front. However, the first digit has already been assumed to be 8. This is a contradiction, and 8 in the front cannot be correct.
Let's assume the 3's at the back of the second and fourth attempts are true. That means that the 4's in the middle of the third and fourth attempts are incorrect, and that the 6 in the back of the third attempt is incorrect. That leaves only the 2 in the front of the third attempt eligible for correctness. The middle digit in the first attempt is the only one eligible for correctness, and it is a 9. Thus, we have exhausted all possibilities for the digits, and incurred no contradictions. The answer is therefore 293.
The password is:
Most important things to notice:
The last digit has to be a 3 or a 6. (If it isn't, then all 4 passwords should have the correct digit on place 1 or 2, which is impossible)
The 4th password shares for each of the 3 digits a digit with another password. This one is crucial, because this sets up a 'chain' of passwords, all linked to each other through different digits.
if the first 8 is correct of the 4th password, then the first 8 of the first password will also be correct. That means that the last digit cannot be a 3 or a 6, which is a contradiction with statement 1.
same for the second 4 digit, because then the 3rd password has number 4 as the right digit, and again, the last digit cannot be a 3 or a 6.
that means that the last digit is a
based on the first password, if it can't be the first 8 and the last 6, the second digit has to be a 9.
With the same principle, looking at the 3rd password, we find that the first digit has to be a 2.
983 and 246 include all the digits together, so the total number of marks must be 3 between the two.
Between 896 and 843, the total number of marks can be no less than 2, meaning it can be 2 (if 8 doesn't exist and 2 does), 3 (both exist or neither does) or 4 (if 8 exists and 2 doesn't), adding up to 5, 6 or 7.
At least one of 8 and 9 must exist. If both do, one of 2, 4 and 6 also does, leaving out 3. 98_, 246, 896, 84_ -> 9_8, _89, contradiction. Only one of them can exist, so either 3 or 6 is in its right place.
If 8 exists, it's either _86 (contradiction) or 843 (nope), so 9 does -> 9_6 (no) or 293 (solution).