A company controls its employees' access to a restricted area with magnetic cards and passwords. Each of the $k$ employees received an anonymous card and chose an $n$-digit numerical password to associate to their card. Suppose the cards were shuffled and randomly redistributed, and let $A$ be an employee.
a) What is the probability that $A$ enters the restricted area using his password and the card he got after the shuffle?
b) If $A$ was able to enter with his password, what is the probability that he received the same card before and after the shuffle?
a) One easily notes that the probability that an employee picked a given password is $p=10^{-n}$. Now let $L$ be how many of the $k$ cards are associated to $A$'s password, that is, how many employees (including $A$) chose $A$'s password. Then the probability is $L/k$.
b) Let $E_1$ be the event "$A$ entered the restricted area" and $E_2$ be "$A$ got his own card after the shuffle". $E_1$ is just the event asked on a, and since $E_2\subset E_1$, this probability is $$\mathbb P(E_2\,|\,E_1)=\frac{\mathbb P(E_2\cap E_1)}{\mathbb P(E_1)}=\frac{\mathbb P(E_2)}{\mathbb P(E_1)} =\frac{1/k}{L/k} =\frac1L\quad.$$
Clearly, all there is left is to calculate $L$. How do I get it deterministically? All I know how it is distributed: $$\begin{align} \mathbb P(L=l\,|\,L\ge1) &=\frac{\mathbb P(L=l\wedge L\ge1)}{\mathbb P(L\ge1)} =\\ &=\frac{\displaystyle{\binom kl}p^l(1-p)^{k-l}I_{\{1,...,k\}}(l)} {\mathbb P(L\neq0)} =\\\,\\\,\\ &=\frac{\ldots} {1-\displaystyle{\binom k0}p^0(1-p)^{k-0}} =\\\,\\\,\\ &=\frac{\ldots}{1-(1-p)^k}\quad, \end{align}$$ and so $$\mathbb P(L=l)=\frac1{1-(1-10^{-n})^k}\binom kl10^{-nl}(1-10^{-n})^{k-l}I_{\{1,...,k\}}(l)\quad.$$