**Interview logical puzzles **are a type of problem or challenge that is designed to test a person's critical thinking, problem-solving, and reasoning skills. These puzzles are commonly used in job interviews for positions that require analytical and problem-solving abilities, such as software development, data analysis, and management roles.

Puzzle Details: There are three keys that open the locks of three different gates. In how many attempts, you can figure out the key for each gate?

**Solution**

There are 2 interpretations to this puzzle, the first interpretation is to identify the key for each gate and open it, and the other is just to identify the key associated with the gate.

according to the first interpretation that is to identify the key for each gate and open it. Assuming that it is always the last key that works, the first lock will take three attempts. Having eliminated one lock/key, the next takes two attempts, leaving one attempt for the last lock.

**3 + 2 + 1 = 6**

hence, To match all the keys to all the locks, the maximum number of tries is 6. The minimum is 3. The formula is 3! or 3*2*1 or 6. The first lock takes at most 3 tries, and the second lock 2 tries as one key was eliminated. The last lock takes 1 try as only 1 key is left.

Best performance: In 3 attempts for 3 gates (getting right in the first attempts for all of the three gates).

Worst performance: In 6 attempts for 3 gates (getting right in the 3rd attempt for the first gate, getting right in the 2nd attempt for the second gate, and getting right in the first attempt for the first gate).

let's solve the problem for the second interpretation which is just to identify the key associated with the gate. Let us take one lock at a time.

Now for one lock, we have three keys but if two keys do not open it, it becomes obvious that a third will do so. So maximum attempt for Lock 1 =2. Similarly, we have 2 keys now for the second lock but if one does not work we know that the other would do so max attempt for Lock 2=1. And for lock three we do not need any attempt bcoz there is only one key left which would be the right key.

So max attempts = 3

We can derive a formula from here only, Suppose there are n locks

**For lock 1 = n-1**

**Lock 2 = n-2**

**Lock n-1=1**

**That becomes 1+2+3……..+(n-1)=n-1C2**

This is an awesome puzzle, too good and keep up the good work.

ReplyDelete