Let's say I have two entirely distinct groupings of things that I wish to combine. The first set contains three items: $A, B, C$, while the second set contains five items: $V, W, X, Y, Z$. Now let's suppose that I have to combine items from these sets to form groups of 3 items, ensuring that 1 and only 1 item from the first set is present, with no repetition allowed. So $A, V, Y$ would not be considered distinct from $A, Y, V$. The basics of permutations and combinations are easy enough to grasp, and even this problem can be approached with reasonable efficiency by treating it as a combination of two elements from the second set, then multiplying the outcome by the number of distinct items in the first set. But what if we were given a range?
Say, for example, that now I say the set of 3 items needs to have 'at least' one item from the first set, but could potentially have more? If more than two distinct sets are introduced and I'm asked to come up with combinations between those, or for larger sets, it gets more complicated still.
These problems keep coming up for me lately, and I'm in need of a scaleable approach.
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.