# Inebriated Unlocking

Paddy returns home after a night of drinking. He safely reaches his front door. Fumbling into his pocket he finds he has ten (seemingly identical) keys. Only one of these is the correct key to his front door. It is dark, and there are no visible distinguishing marks on the keys, nor any way to label them.
Paddy selects one of the keys at random and tries it in the lock. If it is successful, he gets in. If not, he returns the key to his pocket, juggles them around and selects another key at random (it is possible he could select a key he has already tried; possible more than once!). He repeats this process until he eventually gets in.
Question: On average, how many unlock attempts will this technique expect to take him?
Bonus Question: Which unlock attempt is most likely to be successful?
Second Bonus: If, instead of replacing an unsuccessful key back into the same pocket, Paddy discards the bogus key into a different pocket (reducing the number of keys left, and ensuring an incorrect key is not tried more than once), how does this technique reduced the expected number of unlock attempts required to open the door? With this second technique, which unlock attempt is most likely to be successful?

## Selection with replacement

This is Paddy’s first strategy in which he returns an unsuccessful key back into the same pocket.
Let’s define the expected number of unlock attempts to be T.
There is a 1/10 chance that Paddy selects the correct key (taking one attempt), or there is a 9/10 chance that it will have taken him one attempt, been unsuccessful, and so he is back to exactly where he started. We can write this as a self-referential equation
T = 1/10(1) + 9/10(1 + T)
10T = 1 + 9 +9T
T = 10
The expected number of unlock attempts is, therefore, ten attempts.
The expected number of unlock attempts is ten.
As to the bonus question about which unlock attempt is most likely (ignoring the facetious ex-post-facto answer of “the last one he tried!”), seemingly paradoxically, it is his first attempt!
• On his first attempt, he has a 1/10 chance of selecting the correct key.
• To be successful on his second attempt, he must have failed on the first attempt 9/10, and now again has a 1/10 chance of getting the correct key on this second try = 9/10 × 1/10
• To be successful on the third attempt requires failing on the first two attempts (9/10)2 followed by success on the third attempt 1/10 which is (9/10)2 × 1/10
• The longer he keeps going, then less likely it is to be successful on that attempt. On attempt n he is likely to be successful with probability (9/10)n-1 × 1/10
The probabilities get smaller and smaller, but sum up to certainty at the limit. The highest probability is for the first attempt. This is not really a paradox. It's the same basic chance of selecting the correct key, it's just that the longer the 'game is played', the less chance you'll get to be at that stage.