2
$\begingroup$

We would like to count the number of four-digit numbers such that the leftmost digit is nonzero in which at least two digits are the same.

We want to do this in two ways and compare the results.

First way : complementary set

Total number of four-digit numbers such that the leftmost digit is nonzero :

$$9\times 10^3 = 9000 $$

Numbers with pairwaise distint digits :

$$9\times 9 \times 8 \times 7 = 4536$$

So the number of those in which at least two digits are the same is

$$ 9000 - 4536 = 4464$$

Second way : bruteforce

number of numbers with all digits identical :

$$ 9$$

number of numbers with three identical digits :

$$4\times 9 \times 8 + 9 $$ (case containing $0$ and the other case)

number of numbers with two identical digits :

$$6\times 9 \times 8 \times 7 + 3 \times 9 \times 8 $$

We we sum this up we get

$$ 3546 $$

I don't see what is my mistake.

Thanks for your time.

$\endgroup$
2
  • 1
    $\begingroup$ By leading digit is usually meant highest power of 10 like 7 in 7233. $\endgroup$
    – coffeemath
    Mar 15, 2020 at 6:27
  • 1
    $\begingroup$ yes I meant leftmost sorry (edited) $\endgroup$
    – ahmed
    Mar 15, 2020 at 6:29

2 Answers 2

6
$\begingroup$

All four digits the same: $aaaa$
$9$ choices for $a$, total numbers: $1\times 9=9$

Three digits the same: $aaab, aaba, abaa, abbb$
$9$ choices for $a$ and $9$ for $b$, total: $4\times 9\times 9=324$

Two digits the same, other two distinct: $aabc, abac, abca, abbc, abcb, abcc$
$9$ choices for $a$, $9$ for $b$ and $8$ for $c$, total: $6\times 9\times 9\times 8=3888$

Two digits the same, other two also same: $aabb, abab, abba$
$9$ choices for $a$ and $9$ for $b$, total: $3\times 9\times 9=243$

Grand total: $9+324+3888+243=4464$

$\endgroup$
2
$\begingroup$

Actually, both of your solutions are wrong.

$9\times9\times8\times7=4536$ so the number of integers where at least two digits are the same is $9000-4536=4464$

Now we know the answer, let's try to enumerate the digits:

number of 4-digit integers with 4 identical digits: $9$

number of 4-digit integers with only 3 identical digits: $9\times4\times8+9+27$

Because we have ${4 \choose 3}$ ways to choose positions of our (non-zero) identical digits, times 9 (non-zero digits), times 8 (remaining non-zero digits). You forgot to count $27$ additional cases which represent the number of cases where the non-identical digit is $0$ (e.g. $1011$). This can be calculated as $9{4 \choose 3} - 9$ (we subtract 9 for the cases where the integer is of the form $0xxx$)

You could also count all the configurations first (including those that start with $0$) and then subtract $9$ (counted configurations of the form $0xxx$) and then $ 9{3 \choose 2}$ (configurations of the form $0x00$, $00x0$ or $000x$). Again you'd find $10*9*{4 \choose 3} - 9 - 9{3 \choose 2}=324$ such integers

Following this logic, can you count how many 4-digit integers have only 2 identical digits?

$\endgroup$
8
  • 1
    $\begingroup$ the statement says "where "at least" two digits are the same " $\endgroup$
    – ahmed
    Mar 15, 2020 at 7:05
  • 1
    $\begingroup$ @ahmed Yes you're right on the wording, however the answer should be correct (I checked by writing a quick script) $\endgroup$ Mar 15, 2020 at 7:18
  • 1
    $\begingroup$ You're still missing some edge-cases. Where is $1013$ counted? $\endgroup$ Mar 15, 2020 at 7:39
  • 1
    $\begingroup$ I got you thanks $\endgroup$
    – ahmed
    Mar 15, 2020 at 7:47
  • 1
    $\begingroup$ You're almost there! What about two pairs of two digits like 1001? $\endgroup$ Mar 15, 2020 at 8:32

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.