Number of combinations of dice having different number of faces that add to $10$ A function $\textbf{face}_{\mathrm{sum}}$ that takes a vector  $f$ that represents the number of faces of each die, and a positive integer  $s$ , and returns the probability that the sum of the top faces observed is  $s$ .
For example, if $f=[3,4,5]$  and  $s≤2$  or $s≥13$ , $\textbf{face}_{\mathrm{sum}}$ returns $0$, and if  $s=3$  or  $s=12$ , it returns  $\frac13*\frac14*\frac15=\frac1{60}$
$\textbf{face}_{\mathrm{sum}}([2,4,4,6], 10)$
I tried to solve this but I can't find the formula to calculate the number of combination of die faces that add to $10$, as the number of faces are different for each die.
Since max no of possible combination is $6*4*4*2=192$, all I need to find is the number of combination of die faces that add to $10$.
Thanks in advance.
 A: The formula is a bit messy. Suppose there are $n$ dice, and the list is $f=[f_1,f_2,\dots,f_n]$. You want to count the number of integer solutions to the constrained equation 
$$
\begin{align}
x_1+x_2+\dots+x_n &= s\\ 1\le x_i&\le f_i\hspace{2cm} \text{ for }i=1,2,\dots,n
\end{align}
$$
To solve this, first, count the number of solutions without the constraint $x_i\le f_i$. This can be shown to be $\binom{s-1}{n-1}$ (imagine a line of $s$ dots, and you place dividers in $n-1$ of the $s-1$ spaces between the dots). Now, use inclusion exclusion to subtract out the "bad" solutions where some $x_i > f_i$. The result is this:
$$
\bbox[10px,border:solid 2px black]{
\Bbb P(\text{sum of dice }=s) 
= \frac1{f_1\times\dots\times f_n}
\sum_{S\subseteq \{1,2,\dots,n\}}
(-1)^{|S|}\binom{s-1-\sum_{i\in S}f_i}{n-1}.}
$$
There are $2^n$ summands, one for each subset of $\{1,2,\dots,n\}$ (i.e. subset of the available dice). Also, whenever the upper index $s-1-\sum_{i\in S}f_i$ is negative, the binomial coefficient is defined to be zero.
For the special case where $f_1=f_2=\dots=f_n=d$, that is all of the dice have $d$ sides, this simplifies to 
$$
\bbox[10px,border:solid 2px black]{
\Bbb P(\text{sum of $n$ dice with $d$ sides }=s) 
= \frac1{d^n}
\sum_{k=0}^n
(-1)^{k}\binom{n}k\binom{s-1-kd}{n-1}.}
$$
For example, when $f=[2,4,4,6]$ and $s=10$, you get
$$
{1\over 2\cdot 4\cdot 4\cdot 6}\left[
\begin{array}{l}\binom{10-1}{4-1}\\
-\binom{10-2-1}{4-1}-\binom{10-4-1}{4-1}
-\binom{10-4-1}{4-1}-\binom{10-6-1}{4-1}\\
+\binom{10-2-4-1}{4-1}+\binom{10-2-4-1}{4-1}
\end{array}\right].
$$
Terms with $\sum_{i\in S}f_i>s-n$ have been omitted, since in these cases the binomial coefficient is zero.
A: Do you know how to find the number of solutions for an equation like the following?
$$
x_1 + x_2 + ... + x_n = k
$$
given $\forall i \in [n]: x_i \in S_i$ for some set $S_i$.
