# Drunk man with a set of keys.

I found this problem in a contest of years ago, but I’m not very good at probability, so I prefer to see how you do it:

A man gets drunk half of the days of a month. To open his house, he has a set of keys with $$55$$ keys that are all very similar, and only one key lets him enter his house. Even when he arrives sober he doesn’t know which key is the correct one, so he tries them one by one until he chooses the correct key. When he’s drunk, he also tries the keys one by one, but he can’t distinguish which keys he has tried before, so he may repeat the same key.

One day we saw that he opened the door on his third try.

What is the probability that he was drunk that day?

The key thing here is this: let $T$ be the number of tries it takes him to open the door. Let $D$ be the event that the man is drunk. Then

Now, the event that it takes three tries to open the door can be decomposed as

By assumption, $P(D)=P(\neg D)=\frac{1}{2}$. So, we just need to compute the probability of requiring three attempts when drunk and when sober.

When he’s sober, it takes three tries precisely when he chooses a wrong key, followed by a different wrong key, followed by the right key; the probability of doing this is

When he’s drunk, it is

So, all told,

Finally,

(intentionally left unsimplified). So, we get