2853761

https://math.stackexchange.com/questions/2853761/combinations-involving-distinct-sets-of-variables

As shown in the comment, it is about applying many times simple operations.

I will work a larger example, using species and e.g.f. Suppose there are two sorts, M and W and we have 15 M and 17 W. We have to form a team of 3....5 M and say, 6....9 W.

The species formula is:

$$E(M)\cdot[E_3(M)+E_4(M)+E_5(M)] \cdot [E_6(W)+E_7(W)+E_8(W)+E_9(W)]\cdot E(W)$$

The first two factors means that our structure is a subset of size 3 **or** 4 **or** 5 **and** the last two factors means that we have a subset of size 6, **or** 7, **or** 8, **or** 9 for the sort W.

Then we write the e.g.f.

$$exp(m).(\frac {m^3}{3!} + \frac {m^4}{4!}+ \frac {m^5}{5!}). (\frac {w^6}{6!} + \frac {w^7}{7!}+ \frac {w^8}{8!} + \frac {w^9}{9!} ). exp(w) $$

I personally use the maple mtaylor function to truncate exp(x) to a suitable size that covers the biggest cardinals that occur.

Now we are interested in the coefficient of $$\frac{m^{15}}{15!} \frac{w^{17}}{17!}$$ in the above e.g.f. because it represents the answer.

Caution, working with species and e.g.f. is somehow like tightrope walking - it needs some precautions.