<s>[INST] Ways for Two Dice to Sum to 8: $x_1 +x_2 =8$ I am trying to determine the number of ways two dice can be rolled to have a sum of 8. This question can be easily brute-forced, but I want to use a technique that can be applied to similar questions that cannot be brute-forced so easily.
My solution was as follows,
$$x_1 +x_2 = 8, x_1, x_2 \geq 1$$
$$x_1+1+x_2+1 = 8 \rightarrow x_1+x_2 =6$$
Now I can use the stars and bars method.
So $C(6 +(2-1), (2-1))$ should be the answer, which is equal to $7$. But when I brute-forced this question, I only found $5$ solutions. What did I do wrong?
Normally if I wanted to find, say for example, the number of integer solutions to $x_1+x_2+x_3 = 12, x_i \geq 0$, I would apply the same method and do $C(12+(3-1), (3-1))$. What am I doing wrong?
 [/INST] Your sum count is wrong because you are including the cases where some of the $x_i>6.$ For example, $7+3+2=12,$ but you don't want to count that case.

Summary:
The number of ways of getting the sum $S$ from rolling $k$ fair $n$-sided dice labeled $1$ to $n$ is:
$$\sum_{i=0}^{k}(-1)^i\binom{k}{i}\binom{S-in-1}{k-1}$$
You have to be careful evalating this, because $\binom{m}{j}$ is not a polynomial in $m$ for fixed $j$, since it is $0$ when $m<j.$
A trick to make it easier is that you can replace any $S$ with $(n+1)k-S$ and get the same count. So you can always use $S\leq \frac{(n+1)k}{2}$, in which case you can ignore terms with $i>\frac{k+1}{2}$ since then $\binom{S-in-1}{k-1}=0.$

Longer:
This is a case for either generating functions or an inclusion-exclusion argument.
The generating approach applied to the sum of two fair six-sided dice is to compute the coefficients of $x^8$ in:
$$(x+x^2+x^3+\cdots + x^6)^2$$
or the coefficient of $x^6$ in:
$$(1+x+\cdots+x^5)^2$$
Now, this might seem harder, but it isn't, because $1+x+\cdots+x^5=\frac{1-x^6}{1-x}$ So you are seeking the coefficient if $x^6$ in:
$$(1-x^6)^2\frac{1}{(1-x)^2}\tag{1}=(1-2x^6+x^{12})\frac{1}{(1-x)^2}$$
And we have the general result:
$$\frac{1}{(1-x)^{k}}=\sum_{m=0}^{\infty} \binom{m+k-1}{k-1}x^m \tag{2}$$
So when $k=2$ you get:
$$\frac{1}{(1-x)^2}=\sum_{m=0}^{\infty}(m+1)x^m$$
Multiplying by $(1-x^6)^2=1-2x^6+x^{12}$ this means the coefficient of $x^j$ in $(1)$ is:
$$\binom{j+1}{1}-2\binom{j-5}{1}+\binom{j-11}{1}$$
We can't replace $\binom{n}{1}$ with $n$ because we need to $\binom{n}1=0$ when $n<1.$ The term $\binom{j-11}{1}$ is only ever really used to "zero out" the cases where $\binom{j+1}{1}-2\binom{j-5}{1}$ is negative.
When seeking the number of ways to get a sum of $8$, we use $j=8-2=6$ this is $7-2=5.$
When the sum we are seeking, $S,$ is between $2$ and $7$, inclusive, this formula gives us a count of:
$$S-1$$
because the term $\binom{S-7}{1}=0$ when $S\leq 7.$
and when $7<S\leq 12$ this number of ways is:
$$S-1 - 2(S-7)=13-S$$
When $S>12$ all the sum is:
$$(S-1)-2(S-7)+(S-13)=0$$
And when $S<2$ all the terms are zero.

More generally, if you are rolling a set of $k$ $n$-sided dice, you get,via $(2)$, then the number of ways to get a total of $S$ is the coefficient of $x^{S-k}$ in:
$$(1-x^n)^k\sum_{m=0}^{\infty}\binom{m+k-1}{k-1}x^m$$
Thus we get that the number of ways to get a sum $S$ from $k$ $n$-sided dice is: $$\sum_{i=0}^{k}(-1)^i\binom{k}{i}\binom{S-in-1}{k-1}$$
You can also prove this formula using inclusion-exclusion, rather than using generating functions.
Example: when throwing three eight-sided dice, the number of ways to get a sum of $S$ is:
$$\binom{S-1}{2}-3\binom{S-9}{2}+3\binom{S-17}{2}-\binom{S-25}{2}$$
Which yields:
$$\begin{cases}
0&S<3\\
\frac{(S-1)(S-2)}{2}&3\leq S<11\\
27S-S^2-134&11\leq S<19\\
\frac{(25-S)(26-S)}{2}&19\leq S\leq 24\\
0&25\leq S
\end{cases}
$$
You also have, in general, the value for $S$ and $(n+1)k-S$ should be equal. This means that you can always solve for $S$ by using at most the first $\frac{k+1}{2}$ terms of the sum, with the other terms zero.

When dealing with differently-sided dice, you get the same kind of result, but the numerator is different.
For example, a four- and six-sided die rolled together gives you:
$$x^2(1-x^4)(1-x^6)\sum_{m=0}^{\infty}\binom{m+1}{1}x^m$$
Then the coefficient of $x^S$ in this is:
$$\binom{S-1}{1}-\binom{S-5}{1}-\binom{S-7}{1}+\binom{S-11}{1}$$
</s>