# Probability of guessing a password.

the question is roughly this;

A bank requires you to have a 4 digit pin, and a 6 digit/ character password which includes lower and upper case letters. Upon logging in the bank requests 3 digits from your pin and 3 digits from your password, what is the probability some will access your bank account in 3 attempts?

For the pin, the probability is $\frac{1}{1000}$, and for the password the probability is $\frac{1}{62\cdot62\cdot62}=\frac{1}{238328}$.

The probability of guessing both correctly and access the bank account is $\frac{1}{238328000}$.

The solution states that because you have three attempts, the probability to access the account is $$\frac{3}{n}=\frac{3}{238328000}.$$

I think this is wrong however, and the reason is because you wouldn't try the same guess another two times so I think the correct answer is actually, $$\frac{1}{238328000}+\frac{1}{238327999}+\frac{1}{238327998}.$$

Who is right?

• I presume that with "digits" for the password you actually mean "characters" (52 choices for a slot). The probability will be different if some of the digits or letters are the same. Must all digits and characters be different? – Parcly Taxel Feb 2 '17 at 14:57
• the second expression is a good approximation, I think accurately it is $1 - (1 - \frac{1}{238328000})(1 - \frac{1}{238327999})(1 - \frac{1}{238327998})$ that is 'one minus the chance of failing 3 times' what info you get back is a factor, for example whether or not you know which code was wrong - i presume you mean [a-z][A-Z][0-9] for the 62 choices – Cato Feb 2 '17 at 15:03
• I fixed your comment about the digits. It's allowed to have both digits and lower/upper case letters. It doesn't specify whether each input has to be unique sorry. – Ryan Tandy Feb 2 '17 at 15:08
• @cato: nope, the probability for the right code to be in a subset of $3$ among $238328000$ is simply that ratio. – Yves Daoust Feb 2 '17 at 15:17

## 1 Answer

The solution is right and does assume three different guesses.

The probability to succeed at the first attempt is

$$\frac1{238328000}.$$

Then in case of a failure, the probability to succeed at the second attempt is $$\left(1-\frac1{238328000}\right).\frac1{238327999}=\frac1{238328000}.$$

Finally, a third attempt is successful with probability

$$\left(1-\frac1{238328000}-\frac1{238328000}\right).\frac1{238327998}=\frac1{238328000}.$$

The probability to succeed simply grows linearly as the number of attempts over the number of possibilities, and reaches one at exhaustion.