[Math] How many ways can 5 dice produce a total of 20

combinationscombinatoricsdiscrete mathematics

How many ways can $5$ dice produce a total of $20$?

I set up the equation $x_1+x_2+x_3+x_4+x_5 = 20$. The total possible number of combinations is $\binom{19}4$. From there I subtracted the number of possibilities where $1$ of the variables is greater than $6$, which I got as $5\times\binom{13}4$. I also subtracted the possibilities where $2$ variables is greater than $6$, which I used $10 \times \binom74$. I got the $10$ from the number of ways I can choose $2$ of the variables to be greater than $6$ out of the $5$ total variables.

So I have $$\binom{19}4 -5\times\binom{13}4 -10\times\binom74$$

However, I get a negative answer, which can't be right. Can anyone point a flaw in my logic?

Best Answer

As in this answer, we can approach this question using either generating functions or inclusion-exclusion. Instead of counting the number of ways for $5$ numbers from $1$ to $6$ to sum to $20$, we will count the number of ways for $5$ numbers from $0$ to $5$ to sum to $15$ (then add $1$ to each of the $5$ numbers).


Generating Functions

The generating function for the number of ways for $5$ integers from $0$ to $5$ to sum to a given number is $$ \begin{align} \hspace{-1cm}(1+x+x^2+x^3+x^4+x^5)^5 &=\left(\frac{1-x^6}{1-x}\right)^5\\ &=\sum_{k=0}^5\binom{5}{k}(-1)^kx^{6k}\sum_{j=0}^\infty\binom{-5}{j}(-x)^j\\ &=\sum_{k=0}^5\binom{5}{k}(-1)^kx^{6k}\sum_{j=0}^\infty\binom{j+4}{j}x^j\tag{1} \end{align} $$ We can get the coefficient of $x^{15}$ in $(1)$ by choosing $6k+j=15$: $$ \begin{align} \hspace{-1cm}\sum_{k=0}^5(-1)^k\binom{5}{k}\binom{15-6k+4}{15-6k} &=\binom{5}{0}\binom{19}{15}-\binom{5}{1}\binom{13}{9}+\binom{5}{2}\binom{7}{3}\\ &=651\tag{2} \end{align} $$


Inclusion-Exclusion

Without restriction on the size of the terms, using the standard $\mid$ and $\circ$ argument ($15$ $\circ$s and $4$ $\mid$s), there are $\binom{15+4}{4}$ ways to choose 5 non-negative integers that sum to $15$. $$ \text{one sum for each arrangement}\\ 2+4+6+1+2=\circ\,\circ\mid \circ\circ\circ\,\circ\mid \circ\circ\circ\circ\circ\,\circ\mid\circ\mid \circ\circ $$ Now let's count how many ways there are to have terms greater than $5$. There are $\binom{5}{1}$ ways to choose which $1$ term should be greater than $5$. To count the number of sums with $1$ term at least $6$, that would be $\binom{15-6+4}{4}$. $$ \text{consider the red group atomic}\\ 2+7+3+2+1=\circ\,\circ\mid\color{#C00000}{\circ\circ\circ\circ\circ\circ}\circ\mid\circ\circ\circ\mid\circ\,\circ\mid\circ $$ There are $\binom{5}{2}$ ways to choose which $2$ terms should be greater than $5$. To count the number of sums with $2$ terms at least $6$, that would be $\binom{15-12+4}{4}$. $$ 7+0+6+1+1=\color{#C00000}{\circ\circ\circ\circ\circ\circ}\circ\mid\mid\color{#C00000}{\circ\circ\circ\circ\circ\,\circ}\mid\circ\mid\circ $$ There is no way for $3$ terms to be greater than $5$. Inclusion-Exclusion says there are $$ \binom{19}{4}-\binom{5}{1}\binom{13}{4}+\binom{5}{2}\binom{7}{4}=651 $$ ways for $5$ terms to sum to $15$ with each term at most $5$.


Problem in the question

With Inclusion-Exclusion, the terms in the sum are alternating. If the last $-$ sign is changed to a $+$, your answer would be correct.

Related Question