# Crack the lock code

Can any one know how to crack this? I got this as a challenge.

• Welcome to Puzzling! – Deusovi Dec 19 '16 at 7:06
• Reminds me of the game of Mastermind – Kevin Rock Dec 19 '16 at 18:16
• Hard mode: as delightfully noted by @JollyJoker in his/her answer below, this problem is overdetermined and can be solved by omitting clues 4 and 5, the insight for which makes it a far more beautiful puzzle. Try it that way first. – CR Drost Dec 21 '16 at 0:47
• this is pretty easy variation of mastermind question, i am not sure what the difference is? this is also called Electronic Mastermind (Invicta). – Oray Dec 21 '16 at 8:19

The code is:

042

Explanations:

One number is correct and is also correctly placed:

2

One number is correct but wrongly placed:

4

Two numbers are correct and wrongly placed:

0 & 2 incorrectly placed

Nothing is correct:

None of them are in the code

One number is correct but wrongly placed:

0

Approach/Thought Process Chosen

682 - One number is correct and well placed

Correct Number's array - 6,8,2
Confirm Number's array -

614 - One number is correct but wrong placed

Correct Number's array - 8,2,1,4(6 is removed since this clue contradicts the previous one and hence 6 should not be present even in the code-The position of 6 is same in Clue 1 and 2 which mean's it can be pushed out of scope)
Confirm Number's array -

206 - Two Numbers are correct but wrong placed

Correct Number's array - 8,2,1,4,0
Confirm Number's array - 0_2(Since 6 is out of scope, consider 2 and 0 to be in the confirm array list and clue 1 says 2 is well placed )

738 - Nothing is correct

Correct Number's array - 0,2,1,4(8 is removed from the array)
Confirm Number's array - 0_2

780 - One Number is correct but wrong placed

Correct Number's array - 0,2,4(Clues 3 and 5 confirms the position of 0 to be the first. Clues 1 confirms the position of 2. Clue 2 confirms the position of 4 and hence 1 is removed from the list)
Confirm Number's array - 042

• It may just be me... but in my opinion your explanation does not actually explain anything. "One number is correct and is also correctly placed", but why is this specific number the one that's correct, why not any of the other two? – Stephan Bijzitter Dec 21 '16 at 11:55
• @StephanBijzitter-It's just that I posted the answer first with the explanation part later(check the edits). But there were better answers(like this),so didn't feel that I need to add anything else. This one is accepted only due to the reason that it was first. Also, the puzzle was a simple one so I thought I can just post the answer with the reasons. – Techidiot Dec 21 '16 at 12:02
• Sounds like a perfect example of meta.stackexchange.com/questions/9731/… – Stephan Bijzitter Dec 21 '16 at 13:40
• @StephanBijzitter- I have solved many of these recently. I never thought it would require any explanation. But, thought later to add some. Here's one I solved recently last month sample Also, accepting the answer is not my call for sure. You can check out one of my comment where I appreciated the other answer. – Techidiot Dec 21 '16 at 13:46
• @StephanBijzitter- Hope the update doesn't disappoint you. Thanks for pushing me to do that :) – Techidiot Dec 21 '16 at 14:33

You can see from clue 4 that there are no 7, 3, or 8.

You can see from clue 5 that there is a 0 in either the first or second slot, and from clue 3 that it must be in the first slot. That means the code is [0][?][?].

6 cannot be the correct number from clue 1, since it would have to be in the wrong position for clue 2. We already know 8 is incorrect, so 2 must have to be correct, and it must be in the third slot.

This means the code is [0][?][2].

Finally, from the second clue, we can see that one number is correct but in the wrong place. It can't be 6, since we ruled that out already. It can't be 1, since that would be in the correct place. Therefore the code is 042.

• The first clue is not satisfied. – PeteyPii Dec 19 '16 at 7:07
• @QaisarSatti: What? No he didn't. I answered two minutes before him. – Deusovi Dec 19 '16 at 9:03
• @Deusovi no offense but your first answer was wrong. you delete the answer then re-edit it. he added the explanation later. so in my point of view he deserve it – Qaisar Satti Dec 19 '16 at 9:06
• @Qaisar: Yeah, my point was that he added the explanation after I fixed my post. I'm not complaining, just letting you know that he didn't fully answer first. – Deusovi Dec 19 '16 at 9:18
• This explanation is better than the accepted answer because the accepted answer doesn't explain the thought process as well. – Manuel Hoffmann Dec 21 '16 at 11:04

My solution:

• Clues 1 & 2 say number 6 is not included as it cannot be in both the wrong and the right place at the same time
• Clue 3 then says 2 and 0 are included
• Clue 1 then says 2 must be in the last position
• Clue 3 then says 0 must be in the first position
• Clue 2 then has 1 & 4 as possible values, but only 4 is not in the middle position

042, clues 4 and 5 are unnecessary.

• Welcome to Puzzling. We generally don't add answers that say the exact same thing as previous answers. – Mithical Dec 19 '16 at 13:15
• @Mithrandir I don't see another answer that doesn't use clue 4? – JollyJoker Dec 19 '16 at 13:48
• Sorry you had a rude welcome. This is the best answer for efficiency and the very concise format of the answer. Extremely easy to follow. – person27 Dec 19 '16 at 22:15
• Do we have a stance on answers that yield the same result but have different approaches? This one follows a different logic chain the answer that starts at clue 4, and I (personally) find it a useful addition. – Brian J Dec 20 '16 at 20:46
• this one deserves to be the top answer – Sharun Dec 21 '16 at 5:49

From the first clue,

the code contains either a $6$, or an $8$, or a $2$.

From the fourth clue,

it can't be an $8$. Further, based on the second clue, it can't be a $6$...because then the $6$ in the first spot would be both well-placed and wrong-placed simultaneously, which is a contradiction.

Hence there must be

a $2$, and it must be in the third place. Further, there must not be a $6$ or an $8$.

Now by the third clue, the code must contain

a $0$, though not in the second place. Since we know the third place has a $2$, we know that $0$ belongs in the first place. It remains to find the middle number.

By the second clue, the code contains

either a $1$ or a $4$, since we have previously ruled out any $6'$s. Further, the middle number can't be a $1$ since then it would be well-placed in the second clue. Therefore the code is $042$.

As it turns out,

We do not need the fifth clue at all.

I really enjoyed this

Here is how I deduced this:

I started off with clue #4 (nothing is correct).

There we can remove any 7s, 3s or 8s from the other clues.

Knowing this, I moved onto clue #5 (one number is correct but wrong placed)

and was able to remove 7 & 8, leaving 0 behind. According to the clue, 0 is in the wrong place, so we know 0 is in either position 1 or position 2.

We now look at clue #3 (two are correct but wrong placed).

We know one of the two is 0 and due to it being incorrectly placed in this clue, we know for certain 0 is in position 1.
So far, we have our code to be 0XX.

Now if we look at clues #1 and #2. Clue #1 states that one number is correct and correctly placed, and clue #2 states that one number is correct but wrongly placed.

The number 6 is in the same position for both clues, so we can know for certain that 6 is not in our code.

We can now go back to clue #3 and be certain that,

due to 6 no longer being a possibility, our code contains both 0 and 2. We know 0 is in position 1, and because of clue #1, we know that 2 is in position 3. We know this because we have ruled out 6 from the equation just now, and 8 was ruled out earlier.
So far we have 0X2

The last bit is easy. We look at clue #2 again. "One number is correct but wrong placed"

position 1 and position 3 are both occupied by 0 and 2. Our final number cannot be 1, because 1 is in position 2 in our clue, but our clue states our number is wrongly placed. We know from earlier deduction that is isn't 6 either, so the final number MUST be 4. 4 is wrongly placed in this clue.

We move our final number into position 2 and we have:

042

Hope this helps.

Really nice. Didn't know puzzling.se exists...

So my solution is:

042

Because:

1:682 and 4:738 says that 8 isn't in it. makes 1:6X2

and

1:6X2 and 2:614 says that 6 dosn't match eighter 'cause 6 can't be right and wrong placed at once. makes 1:XX2

and

3:206 is in fact 0XX 'cause 2 is the last digit and 6 is not part of it. but 0 is on the wrong place. makes 0XX.

Again line 2

2:614 wich is X14 'cause 6 id off. 4 is place wrong. only the numer in the middle is missing: makes X4X.

All together:

XX2 | 0XX | X4X => 042

I got

042

I got my answer by starting at section 4 then 5 then 1 and 2 gave me the answer for 3 which solves the puzzle.

Here's my dumb logic hahaha, did it in notepad:

6-x-2 (one correct and place) C
not 7 or 3 or 8
x-x-0 (one correct and wrong place)
2-0-6 (2 correct but wrong place) A
6-1-4 (one correct but wrong place) B

0 is correct
0-x-x

2-0-6 (2 correct but wrong place) A
6-1-4 (one correct but wrong place) B
6-x-2 (one correct and place) C

A: 2 or 6 is right, but wrong place
B: 6 or 1 or 4 is right but in wrong place
C: 6 or 2 correct and right place

6 is in all 3, if we assume it is right, then
6 is not in 3rd place, it is not in first place
and it is correct in first place, so illogical
therefore 6 is wrong, take out 6

A: 2 is right, but wrong place
B: 1 or 4 is right but in wrong place
C: 2 is correct and right place

therefore: 0-x-2

remainder:

B: 1 or 4 is right but in wrong place

4 is in the wrong place, therefore: