Doors and Keys

Probability Level pending

You are in a hallway with 6 doors in it. You also have 6 keys and each key opens only one door. You don't know which key opens which door. In maximum, how many tries you will have to do to know which key opens which door?


The answer is 15.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Let's say that you tested 5 keys in the first door, and none of these keys worked. Then, the sixth key left must open this door, because one key opens only one door.

Now you have 5 keys to five doors. You tested 4 keys in the second door and none of these keys worked. Then, the fifth key left must open this door.

Repeating this process until the fifth door, the number os tries you did will be 5 + 4 + 3 + 2 + 1 = 15 5+4+3+2+1=15 .

I have already given a problem like this before

Unlock the Locks

Kushal Bose - 4 years, 3 months ago

Log in to reply

I saw your problem only now. This problems appeared in a test I made last year

Victor Paes Plinio - 4 years, 3 months ago

Log in to reply

Its ok it just a coincidence

Kushal Bose - 4 years, 3 months ago

How do you know that this is the optimum approach?

Calvin Lin Staff - 4 years, 3 months ago

Log in to reply

We need to maximize the maximum number of tries. Then we can maximize the number of fails until you found the right key. As I said, if you try and fail with 5 keys in the first door, the 6th key must open it. Maximizing the number of fails you can try all wrong keys in the doors until you fond the right one.

In other words, you only have to test the wrong keys to find the right one. We have 5 wrong keys to the first door. After try all of these keys, you get the right one. Doing this same logic in the other doors, you will try the keys 15 times.

Victor Paes Plinio - 4 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...