Possibilities of 4-digit iphone code

combinatoricsprobability

To unlock an iPhone, a user must enter the correct 4-digit pin code. How many 4-digit pin codes are possible, and if you get 10 attempts, what is the probability of randomly guessing the correct code in 10 attempts?

I was following this video:
https://www.youtube.com/watch?v=DZacSLax3aM

but I couldn't really understand why the answer is what is is. If I already guessed 1 combination and if it is was wrong, wouldn't the number of possible outcomes (the denominator) decrease by 1 with the subsequent attempt?

Best Answer

Welcome to Stack Exchange!

Unfortunately people on this site are not going to take the time to go away from the site to look at a video, especially if they don’t even know how long it is going to take.

My answer is therefore based on your question only. But I hope I have guessed the question right!

The number of possible codes is clearly $10000$. You just multiply to get that.

If you make one guess, your chance of getting it wrong is $\frac{9999}{10000}$, so your chance of getting it right is $\frac{1}{10000}$.

With your second guess there are only $9999$ possibilities left, as you said, so the chance of getting two guesses wrong is $\frac{9999}{10000}\times\frac{9998}{9999}$, which equals $\frac{9998}{10000}$. So your chance of not getting it wrong in two guesses is $\frac{2}{10000}$.

I hope you can take it on from there.


This is the simplest way of looking at it. But you could put it together differently as well.

Chance of getting first guess right: $\frac{1}{10000}$.

Chance of having to make a second guess: $\frac{9999}{10000}$, which you then multiply by the chance (given that you are making that second guess) of getting that guess right, which is $\frac{1}{9999}$.


You may find it interesting that for such a large number of possibilities and such a small number of guesses, the chance of getting it right from ten random guesses is practically the same as the chance of {getting it right from ten guesses where you take care to make each guess different. Random = $1-(\frac{9999}{10000})^{10}$, which is $0.99955$ chances in a thousand rather than one chance in a thousand.