-3

How many 4-digit numbers can be crafted from $\{ 1,2,3,4,5 \}$ under the following conditions:

$1$ can not appear two or more times ($1142$) is not valid
$2$ can not appear three or more times ($2242$) is not valid
$3$ can not appear 4 times ($3333$) is not valid

With $4$ and $5$ there are no conditions. The thing is that a number can not appear more than its value say. That's why with $4$ and $5$ there are no conditions.

Obviously, 3204 is not valid.

After this condition, how could I compute the number of possible 4-digit numbers?

Mario
  • 17
  • The rules are not clear. Is $5555$ valid? Regardless of the details, Inclusion Exclusion seems indicated. – lulu May 16 '22 at 21:37
  • @lulu Yes, it is. I've edited the body to be more clear. – Mario May 16 '22 at 21:41
  • So, when you say that, for example, $1$ can only appear $1$ time, you meant "$1$ can not appear more than $1$ time". Ok. As I say, Inclusion Exclusion ought to work. – lulu May 16 '22 at 21:42
  • Yes, sorry. I'll change it. – Mario May 16 '22 at 21:43
  • @lulu could you give me a tip or a hint? I don't know how to start – Mario May 16 '22 at 21:49
  • Usual Inclusion Exclusion. Start with the total (no restriction). subtract those that violate (at least) one restriction, add back those that violate at least two, subtract those that violate at least three. And so on. – lulu May 16 '22 at 22:00
  • Should say, it's not particularly difficult to do this directly. Let $(a,b,c,d,e)$ denote the number of $1's$, $2's$, etc in your string. Thus $a+b+c+d+e=4$. Now just list the allowable $5$-tuples and count the number of strings you can with each. A bit tedious, but there really aren't many allowable $5-$ tuples. – lulu May 16 '22 at 22:10
  • See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula. When considering how many $4$ digit numbers there are, that ignore the constraints, there are $5$ choices for each digit. Therefore, the starter enumeration is $\displaystyle ~(5)^4.$ – user2661923 May 16 '22 at 23:13

3 Answers3

0

Hint: There are $T = 5^5 = 3125$ possible combinations without conditions. Calculate how many combinations violate the conditions and substract from $T$.

lafinur
  • 3,322
0

You essentially want to extract all $4$ digit permutations from $1223334444555555$

An alternative to inclusion-exclusion is to use generating functions to find the coefficient of $x^4$
in $4!(1+x)(1+x+\frac{x^2}{2!})(1+x+\frac{x^2}{2!}+\frac{x^3}{3!})(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!})^2$

$(1+x+\frac{x^2}{2!})$, eg represents $2$ occurring $0,1\; or\; 2$ times. Note that $x^2, x^3, x^4$ have been divided by $2!,3!,4!$ respectively to get the correct number of permutations. Also, $5$, too, has been restricted to $4$ repetitions because the word is only $4$ letters long.

I get an answer of $494$, but you should check.

0

Using EGF, compute by pen and paper.

The EGF of 1's: $e^{x}-\frac{x^{2}}{2!}-\frac{x^{3}}{3!}-\frac{x^{4}}{4!}$

The EGF of 2's: $e^{x}-\frac{x^{3}}{3!}-\frac{x^{4}}{4!}$

The EGF of 3's: $e^{x}-\frac{x^{4}}{4!}$

The EGF of 4's, 5's: $e^{x}$

We get EGF:

$G\left ( x \right )=\left ( e^{x}-\frac{x^{2}}{2!}-\frac{x^{3}}{3!}-\frac{x^{4}}{4!} \right )\left ( e^{x}-\frac{x^{3}}{3!}-\frac{x^{4}}{4!} \right )\left ( e^{x}-\frac{x^{4}}{4!} \right )e^{2x}$

The desired number is the coefficient of $\frac{x^4}{4!}$ term in the expansion of G(x):

$\left [ \frac{x^{4}}{4!}\right ]G\left ( x \right )=\left [ \frac{x^{4}}{4!} \right ]\left ( e^{x}-\frac{x^{2}}{2!}-\frac{x^{3}}{3!} \right )\left ( e^{x}-\frac{x^{3}}{3!} \right )e^{3x}-3=\left [ \frac{x^{4}}{4!} \right ]\left ( e^{5x}-\frac{x^{2}e^{4x}}{2!}-\frac{x^{3}e^{4x}}{3!}-\frac{x^{3}e^{4x}}{3!}\right)-3=5^{4}-6\cdot4^{2}-2\cdot4\cdot4^{1}-3=\boxed {494}$

OGFandEGF
  • 124
  • 8