A similar problem to this one is the one that initiated me to the art of using the generating functions, I’ll tell you a version which has less calculations to make.

If you roll a complete set of DnD dice, in how many ways can you obtain 13 as sum of their results?

Just for you to know, a complete set of DnD dice is made up of 6 components: 4-faced die, 6-faced die, 8-faced die, 10-faced die, 12-faced die, 20-faced die. Each of them has, on its faces, all the numbers in a range that goes from 1 to the number of its faces.

Now, let’s write its generating function. Keep in mind we have to find its 13th degree coefficient.

Each die can be written as:

where n is the number of its faces.

If we multiply all the polynomials we get a roll of all the 6 dice:

It may seem a difficult polynomial division to perform, but there’s actually a trick which simplifies calculations. By a very straightforward use of derivatives, one notices this series expansion

That’s how we’ll write , but now we have to expand the rest of the polynomial (actually we can try to only find the terms of degree less than or equal to 13 but I’ll show the complete one).

This must be multiplied by the series expansion we previously discussed.

Now, to reach 13, we need to consider to consider the terms of degree 6, 10 and 12 of the expanded polynomial and, hence, the terms of degree 7, 3 and 1 of the series expansion.

The result is:

This is a very nice trick to employ in your combinatorics problems.