0
$\begingroup$

Given the digits $0,1,...,9$, the numer of possibilities to construct a PIN code is $10^4$ (zero can be at the beginning since it's a code and not a number).

I need to find the number of PIN codes that have at least two of the same digits.

I tried using two ways to calculate, but got different results and I could really use some help figuring out why it happend.

First solution:

The number of PIN codes with all distinct digits is $10\times9\times8\times7$. So the number of PIN codes with at least two of the same digits should be $10^4 - 10\times9\times8\times7 = 4960$.

Second solution:

If a PIN code has at least two of the same digits, it has exactly two, three or four of the same digits.

For having exactly two of the same digits, I have $10$ choices for what digits should be the same. I then choose their position in the code, ${4 \choose 2}$ choices for that , and then there are $9\times8$ choices for the other two digits. All in all, there are $10\times{4 \choose 2}\times8\times9=4320$ possibilities for that.

For having exactly three of the same digits, again there are $10$ choices for what digits should be the same. For choosing their position in the code there are ${4 \choose 3}$ ways, and $9$ ways to pick the fourth digit. So there are $10\times{4 \choose 3}\times9 = 360$ possibilities for that.

Lastly, the number of possible ways to construct a PIN code with exactly 4 of the same digits is $10$, which is trivial $(0000,1111,...,9999)$.

Summing up all of the above, we get that the number of possibilities is $4320+360+10 = 4690$.

I could really use some help figuring out why one (or both) of my methods is wrong.

Thanks!

$\endgroup$
7
  • $\begingroup$ Doesn't $0000$ have only one distinct digit? You have totally misinterpreted the question. $\endgroup$ Jan 6 at 16:15
  • $\begingroup$ Hi, my apologies, since English is not my main language I totally misinterpreted the meaning of the word distinct. I edited it, hope it makes sence now. $\endgroup$
    – Orokusaki
    Jan 6 at 16:23
  • 5
    $\begingroup$ You missed the case where you have two pairs, for example 1122 or 3443. $\endgroup$ Jan 6 at 16:26
  • 1
    $\begingroup$ No pairs give you $270$ and not $540$. You are double counting. $\endgroup$
    – Math Lover
    Jan 6 at 17:14
  • 1
    $\begingroup$ Say you choose $1$ and the next number is $2$. Your $4C2$ will count 1 2 1 2, 2 1 2 1 and so on. Now when the first number is $2$ and the next number is $1$, you again count them. $\endgroup$
    – Math Lover
    Jan 6 at 17:19
0
$\begingroup$

Ok, so thanks for the help guys, it turns out I wasn't counting pairs of the same digit. The way I calculated it:

We have $10\times9$ choices for the two pairs of identical digits. Next, we need to find out how many possibilities are there to divide them to pairs. This is much like dividng $2n$ people to pairs, when $n=2$.

All in all we get: $10\times9\times\frac{4!}{2^{2}\times2!} = 270$.

Summing this with the above we get $270+4690=4960$, which is the correct answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.