I'm trying to find the "math" way to calculate the number of elements in X amount of packs, those packs made out of 5 "kinds" The thing is the following, i have 5 colours with same or different amount of elements per colour.
For example, let's say i have pink, peach, purple, mint, and green. And I have varing amounts per colour... so:




Colour
Amount




Pink
242


Peach
250


Purple
240


Mint
240


Green
252




I would like to be able (if possible) to calculate how many packs of 3 colours (same amount per colour in a pack) i could make (and the amount per colour in that pack), i realize there's a lot of combinations available, but if i could restrict the amount of packages i can make (let's say not more than 10 packs) that would be helpful, i'm not sure how to do the math on it, after i have the math i'll translate it into code.
Example of end product after applying the "formula" if possible, once or many times until no units are left, or the least amount possible, this example here was made manually via "trial and error":




Colour
Units
80
70
70
80
80
10
10
Left




Pink
240
80

70

80

10



Peach
240

70
70

80
10
10
0


Purple
240

70

80
80
10

0


Mint
240
80

70
80

10

0


Green
240
80
70

80


10
0




Hopefully there's a way. Thanks in advance to anyone trying!
PS: i hope the tags are okay, i'm not sure really.
 A: Note that if you have three of each color you can make five packs from them.  This tells you that your can use $240$ of each color to make $400$ packs.  This leaves you $24$ cards left.  You can make two packs of pink, peach, green which then leaves $8$ peach and $10$ green.  It should seem likely that you can mix things up a bit and use all the cards, getting $6$ more packs for a total of $408$.  I would trade two peach and four green into existing packs, pulling out blue each time.  You can then make six more packs with what is left.
A: let me suppose the amounts of candies are smaller, like 32, 40, 30, 30 and 42.
There are $10$ types of bags. The type that contains pink, peach and purple candies may be described as
$$ T_{khl} = 1 + k.h.l+ (k.h.l)^2 + (k.h.l)^3 + \cdots + (k.h.l)^{42} $$ meaning that it could be none of them or $1$ of such bag, or $2$, until a maximum of $42$.
The type that contains purple, mint and green is described as
$$  T_{lmg} = 1 + l.m.g + (l.m.g)^2 + (l.m.g)^3 + \cdots + (l.m.g)^{42} $$
To obtain all the possibilities of distribution, we have to multiply all ten enumerations
$$ T_{khl} \times T_{khm} \times \cdots \times T_{lmg} $$
and then read the coefficient of $$k^{32}h^{40}l^{30}m^{30}g^{42} = 110241$$.
These enumerating expressions are improperly named "generating functions".
They are not functions,
they list and not generate,
Plus sign is not a sum but a disjunction
and the multiplication sign is a conjunction.
