# crack this code #1965

Using the clues provided, determine the 'password'.

501 — Two correct numbers in wrong places
135 — One correct number in the right place
483 — All numbers are wrong
167 — One correct number in wrong place
430 — One correct number in the wrong place

• +1 for reminding me that I haven't played Mastermind in a while...such a fun game. – Brandon_J Jan 29 '19 at 19:06
• While Mastermind technically has 4 digits, I figured it was close enough that tagging it wouldn't be too off-putting. Glad I reminded you of the game. :) – Ian MacDonald Jan 29 '19 at 21:10

[5, 0, 1]: 2
[1, 3, 5]: 1


So either 5 or 1 is correct, but not both.

[4, 8, 3]: none.

[1, 6, 7]: 1


Because 1 is in the same place as it was before, but the "one correct" is in the wrong place, it cannot be a right number. This means that 5 (from earlier) is definitely the last number, and also one of either 6 or 7 is correct, but in the wrong place.

[4, 3, 0]:


We know from above that 4 and 3 are both wrong, and we deduced from the last step that 1 was not a number, meaning the first line shows us that 5 and 0 are both numbers, so this actually gives us no new information on which numbers, but does tell us that 0 is still in the wrong place.

This means that we have "0 x 5" with x being either 6 or 7. From the second-last line, we know that the correct number is in the wrong place, so it can't be 6 (which was in the middle).

The final answer is: 0 7 5.

• I think it's awesome that you got to the conclusion relatively simply, but didn't get there by the much more important piece of info those first two rules gave: switching from 0 to 3 gave one less correct number - which means 0 has to be one of the three numbers (and, conversely, 3 cannot.) – Kevin Jan 29 '19 at 22:20

The following are my musings to find the answer:

Starting with 430 (Rule 5):

4?? Eliminated by rule 5
?4? Eliminated by rule 3
??4 Eliminated by rule 3
3?? Eliminated by rule 3
?3? Eliminated by rule 5
??3 Eliminated by rule 3
0?? Remaining - Now Rule 6
?0? Remaining - Now Rule 6
??0 Eliminated by rule 5

Starting with 501 (Rule 1):

5?1 Eliminated by rule 1
51? Eliminated by rule 1
15? Eliminated by rule 6
1?5 Eliminated by rule 2
?15 Eliminated by rule 6
?51 Eliminated by rule 1
50? Eliminated by rule 1
5?0 Eliminated by rule 1
?50 Eliminated by rule 2
?05 Eliminated by rule 1
0?5 Remaining - Now Rule 7
05? Eliminated by rule 2
?01 Eliminated by rule 1
?10 Eliminated by rule 2
1?0 Eliminated by rule 6
10? Eliminated by rule 1
01? Eliminated by rule 2
0?1 Eliminated by rule 1

Starting with 167 (Rule 4):

1?? Elimated by rule 4
?1? Elimated by rule 1
??1 Elimated by rule 7
6?? Elimated by rule 7
?6? Elimated by rule 4
??6 Elimated by rule 7
7?? Elimated by rule 7
?7? Remaining - Now Rule 8
??7 Elimated by rule 4

Combining the two new rules, 7 and 8 gives:

Result 075

I've found the answers too complicate, so I share mine. Only three rules are needed:

501 — Two correct numbers in wrong places

So, only one of those numbers should be removed. Which one?

135 — One correct number in the right place

Since this shares 2 numbers with the first one, the 3 cannot be the correct one. (If the 3 comes into play, the rule would give info about 2 numbers instead of one). So, from the previous rule, we should remove only the 1 or the 5. Now we know the number has a 0 in one side, and starts with 1 or end with 5. Only 2 chances: 1_0 or 0_5.

167 — One correct number in wrong place

This number start with 1 as the previous one, and the 1 can't be in right and wrong place at the same time. So, we have only one possibility now: 0_5. We are only missing the middle number and can't be the 6 because it's already in the middle and not in the right place. So the only option left is the 7. -> 075.

• Welcome to Puzzling SE! I'm a little confused on your answer for 501, can you elaborate more? – North Jan 30 '19 at 3:06
• Excellent observation about the 3 to get it down to three rules! – par Jan 30 '19 at 20:31

075

because

0 Is right because there are two numbers right in first condition. And other one is wrong because of second condition in which 5 or 1 Has to be wrong. and From last condition 0 is selected and other 2 values got discard because of the 3rd condition. We got the position of the 0 from these two upper conditions. as 0 is wrong at second place in first condition and 0 is also wrong at last place in last condition.
5 Is selected from first condition if we select 1 then we get only 2 numbers as we need 3 to make the key. 5 is also right in condition second in which we also got the right position of the 5.
7 is right because of 4th condition as the other two number which is 1 is wrong due to first and second condition because we selected 5 and 6 is also wrong due to the position of 6. we need number that fits in position between 5 and 0. because 7 is at wrong place that fits at second position.
As it satisfy all conditions
501 — Two correct numbers in wrong places(5,0, As 1 or 5 get discard in second condition, so i took 5)
135 — One correct number in the right place(5, As we can select only one that should be from first condition.)
483 — All numbers are wrong(If presented above shall be discard.)
167 — One correct number in wrong place(7, Both the last and first place is booked thats why only chance 7)
430 — One correct number in the wrong place(0, as we took in the first step.)

Only the first four rules are necessary to find the answer.

a. Via rules 2 & 3 the answer contains a 1 or a 5 but not both.
b. Via (a), rule 1, and rule 2 the 1 or 5 in the answer is not in the middle.
c. Rules 2 and 4 contradict if 1 is in the number, so 1 is not in the number, therefore 5 is at the end.
d. Via (b), (c), and rule 1 the answer contains a 0 which is not in the middle, therefore 0 is at the front.
e. Via (c), (d), and rule 4, 7 is in the middle.

I will share my process:

• Notes of format !5 | !0 | !1 means that the first position can't be 5, second can't be 0, etc.
• Possible is short for values which are possible and also have been previously discussed
• Impossible represents values which have been ruled out
• Definite represents values which have been confirmed to exist, though makes no statement on order
• Conditions represent restrictions on password. For example: !(1+4) means the code cannot contain both one and 4

Step one:

!5 | !0 | !1

Possible: 0,1,5
Conditions: !(0+1+5)

Step Two

!3!5 | !0!1!5 | !1!3
Possible: 0,1,3,5
Conditions: !(1+3+5)!(0+1+5)!(1+3)!(1+5)!(3+5)

Step Three

!5 | !0!1!5 | !1
Possible: 0,1,5
Impossible: 3,4,8 -> as defined
Conditions: !(0+1+5)

Step Four

!1!5 | !0!1!5!6 | !1!7 -> 1 is eliminated
Possible: 0,5,6,7
Impossible: 1,3,4,8
Conditions: !(1+6+7)!(1+6)!(1+7)!(6+7)

Step Five

!5 | !0!5!6 | !7 -> !5 | 7 | !7 -> 6 is eliminated here, as explained in below:
Possible: 0,5,6,7
Impossible: 1,3,4,8
Conditions: !(6+7) -> since the middle term requires 7 (!0!5!6), and !(6+7), 6 is removed

Conclusion

Possible: 0,5,7
First Term: !5 -> 0 (since 7 is second term)
Second Term: 7
Third Term: 5
.
0 7 5

1) 501
2) 1X5 — 3 gets eliminated by the next clue
3) XXX — All eliminated
4) X67 — 1 gets eliminated for being in the "wrong" place here but the "right place" on Clue 2
5) XX0 — 4 and 3 gets eliminated by clue 3, leaving 0

So 0 is in the 1st position, because of the first clue that says it can't be in 2nd

2) XX5 — The 0 took the 1's place, so only 5 is left

So we have 0X5 at this point.

4) XX7 — 1 gets eliminated by clues 1 and 2, and 6 would be in the "right" place if it was one of the numbers

Rule 1) 501 — Two correct numbers in wrong places
Rule 2) 135 — One correct number in the right place
Rule 3) 483 — All numbers are wrong
Rule 4) 167 — One correct number in wrong place
Rule 5) 430 — One correct number in the wrong place

Starting from the most elimination Rule 3

Because of Rule 3, Rule 5 proves that 0 is at position 1 or 2.
But 0 can't be at position 2 because of Rule 1.

So 0 is at position 1.

Finding the 2nd digit

Because of Rule 1, and we know about 0, it has to contain a 1 or a 5, but not both.
And because of Rule 2, it can't be 1 because that position is already taken by 0.

So 5 is at position 3.

The remaining digit

Then there's only the 2nd position to figure out.
And because of Rule 4, it can't be 6.