6
$\begingroup$

The numbers to be used are : 2, 3, 4, 4, 5

The way I approached this is:

Total number of combinations possible is :

$$\frac{5!}{2!}$$

Total number of combinations starting with 4 :

$$4!$$

Total number of combinations starting with 5 :

$$\frac{4!}{2!}$$

$\therefore$ the total number of numbers $<$ 40,000 :

$$\frac{5!}{2!}-\Big(4!+\frac{4!}{2!}\Big)$$

I came across with this question and I don't have access to the solution.

I'm not confident if this is correct.

$\endgroup$
  • $\begingroup$ You must use the digits $2,3,4,4,5$ ? $\endgroup$ – user252450 Dec 17 '15 at 7:56
  • $\begingroup$ The solution is correct .Try to look at it again and understand why it's correct . $\endgroup$ – user252450 Dec 17 '15 at 8:01
  • $\begingroup$ @ComplexPhi Yes we must use those digits only $\endgroup$ – Siddharth Thevaril Dec 17 '15 at 8:04
8
$\begingroup$

You have to use digits $2,3,4,4,5$, and it can't exceed $40000$. That means, you can't start your number with $4$ or $5$. That leaves you with the option to start with $2$ or $3$. If you started your number, you still have $4$ digits, but $2$ of them are the same, so the total possibilities are $\frac{4!}{2!}$, and you multiply this with $2$, since you can start with either $2$ or $3$, therefore the answer is $24$. Your solution is correct, but I just wanted to show you a "clearer" one.

$\endgroup$
9
$\begingroup$

To double-check the answer, you can use brute force:

$ python
>>> sum(sorted(str(x)) == sorted(str(23445)) for x in range(40000))
24
$\endgroup$
  • $\begingroup$ Really nice code, +1 :) $\endgroup$ – Atvin Dec 17 '15 at 8:38
  • 1
    $\begingroup$ Alternatively, Here is Mathematica code (it's quicker in theory, since it checks only 60 permutations and not 40000 numbers): Count[Map[Total[10^(Range[5] - 1)*#] &, Permutations[{2, 3, 4, 4, 5}]], x_ /; x < 40000] $\endgroup$ – Meni Rosenfeld Dec 17 '15 at 10:34

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.