Probability problem with $n$ keys and $k$ locks Let's say we have $n$ keys and $k$ locks on a door, with $n \ge k$. The $n$ keys are different, i.e. only $1$ key goes into a specific lock.
Also every lock has a key that goes to it (but some of the keys may be "duds").
What is the probability of unlockin gthe door on the $M$th attempt?
If we had $n$ keys and $1$ lock then obviously the probability to unlock on $M$-th attempt would be $\frac1n$, but now we have more locks.
So let's say we have $11$ keys and $2$ locks, what the probability that while we unlock we use up $3$ keys that are bad?
Is it $\frac1{11}\cdot\frac1{11}$ because we try the key on both doors before discarding it? If it doesn't unlock any door we don't use it again.
What if we have more locks?

Note: I think the question may be defining "attempt" as trying the key on a single lock. In this answer, I took "attempt" to be trying one key (on every lock).
The question is: if there are $n$ keys and $k$ locks, and a random ordering of the $n$ keys, what is the probability that the locks are all unlocked in $m$ steps, where $k \le m \le n$?
Overall, we randomly choose $k$ of the $n$ keys to be the correct ones, and this can be done in $\binom{n}{k}$ ways. The question is then the probability that the last correct key is the $m$th one. The number of ways to do that is $\binom{m-1}{k-1}$, since we have to choose which of the $m-1$ first keys are the $k-1$ remaining correct ones.
Therefore the answer is
$$
\frac{\binom{m-1}{k-1}}{\binom{n}{k}}
= \frac{(m-1)! \cdot (n-k)! \cdot k}{(m-k)! \cdot n!}.
$$
Note the special cases:


*

*When $k = 1$, this gives ${(n-1)!}/{n!} = 1/n$,  which is what you computed.

*When $m = k$, this gives $1 / \binom{n}{k}$, because the correct keys must all come at the front.

*When $n = k$, this gives $1$ if $m = n$, $0$ otherwise.
