# Find the probability that no more than three attempts will be required to open the lock

Of the five keys, one is suitable for the lock. The key that did not fit when trying to open the lock is put aside.

We need to find the probability that no more than three attempts will be required to open the lock.

I tried to use the following idea:

Let's write down the events:

1. A = lock opened by the first key
2. B = lock opened by the second key
3. C = lock opened by the third key

Then we have probabilities:

We have 1 good and 4 bad keys (5 total):

P(A) = 1/5 = 0.2

Then we have the probability 4/5 that we take the wrong key.

Now we have 1 good and 3 bad keys (4 total):

P(B) = 4/5 * 1/4 = 1/5 = 0.2

Then we have the probability 3/4 that we take the wrong key.

Now we have 1 good and 2 bad keys (3 total):

P(C) = 4/5 * 3/4 * 1/3 = 1/5 = 0.2

This way we can sum it up and get a probability is 0.6.

I fear that my solution is poor and unfounded, and I ask for help to valid and improve it.

Let me provide a different solution that is often applied to such problems.
The trick is to use the opposite of what we want to find first. And then subtract its probability from $$1$$.

Let:
P(A)=P(1st attempt successful)=1/5
P(B)=P(2nd attempt successful)=1/4
P(C)=P(3rd attempt successful)=1/3

You found - correctly - that \begin{aligned}P(\text{one of first 3 keys fit}) &=P(A\lor B\lor C)\\&= P(A)+ P(\lnot A\land B) + P(\lnot A\land \lnot B\land C)\\ &= \frac 15 + \frac 45\cdot \frac 14 + \frac 45\cdot \frac 34\cdot \frac13\\ &= \frac 15 + \frac {\not 4}5\cdot \frac 1{\not 4} + \frac {\not 4}5\cdot \frac{\not 3}{\not 4}\cdot \frac1{\not 3}\\ &=\frac 35\end{aligned}

If we find the opposite first, we get: \begin{aligned}P(\text{one of first 3 keys fit})&=1-P(\text{none of the first 3 keys fit}) \\ &= 1 - P(\lnot A\land\lnot B\land\lnot C)\\ &= 1-\frac 45\cdot \frac 34\cdot \frac 23\\ &= 1-\frac {\not 4}5\cdot \frac {\not 3}{\not 4}\cdot \frac 2{\not 3}\\ &= \frac 35\end{aligned}

• Thank you for answer! But let's specify the following probabilities: I guess that P(A)=1/5; P(B)=1/4; P(C)=1/3, isn't it?
– Egor
Mar 8, 2020 at 5:06

There are 5 keys, 1 opens the lock and we choose 3 randomly without replacement. The probability that the "good" key is among the 3 chosen ones is $$\frac{\binom11\binom{4}{2}}{\binom{5}{3}}= 0.6$$ The same as your answer. Your solution is fine.

Your solution and also Mick's solution are correct. I just want to point out how underutilized permutation is for probability:

The right key is chosen first, second, or third, $$3$$ possibilities. The other $$4$$ order of taking can be assigned to the remaining $$4$$ keys in $$4!$$ ways.

Probability is $$\frac{3\times 4!}{5!}=0.6$$

# generalization:

In Mick’s solution, the probability of taking the correct keys out of $$n$$ keys within the first $$k$$ takes is $$\frac{\binom{1}{1}\binom{n-1\ \ }{k-1\ \ }}{\binom{n}{k}} =\frac{k}{n}$$

In my solution, it is $$\frac{k\times (n-1)!}{n!}\ \ =\frac{k}{n}$$

You have an list of five keys, the order uniformly randomly decided, of which you require a single specific key to happen in one of the first three positions of the list.

The probability of this occuring is three (good positions existing) out of five (total positions available), or $$\frac{3}{5}$$.