Choosing n objects from k types of objects, each of which is in limited supply Suppose I wanted to light my Christmas tree. In my basement, I find a cord that has $5$ sockets in which I can screw bulbs. I also locate $5$ red bulbs, $4$ green bulbs, and $3$ blue bulbs. How many unique strings of bulbs can I form? Let's say that reversed sequences do not count as unique sequences (so RRRGB and BGRRR would count as one unique sequence).
I do not know of an efficient approach to solving this type of problem. My initial thought is that the only way to compute the answer manually is through tedious case-by-case analysis. Thoughts? 
 A: You can use dynamic programming. The first step is to find the number of unique strings without modding out by reversion. Consider the expression
$$ (r+g+b)^5 = b^5+5 b^4 g+5 b^4 r+10 b^3 g^2+20 b^3 g r+10 b^3 r^2+10 b^2 g^3+30 b^2 g^2 r+30 b^2 g r^2+10 b^2 r^3+5 b g^4+20 b g^3 r+30 b g^2 r^2+20 b g r^3+5 b r^4+g^5+5 g^4 r+10 g^3 r^2+10 g^2 r^3+5 g r^4+r^5. $$
What you want is the sum of coefficients of $r^ig^jb^k$ where $i \leq 5$, $j \leq 4$, $b \leq 3$. When you do the computation, there is no need to keep track of monomials which violate this constraint, and this leads to the dynamic programming solution, which is a slightly more efficient version of the generating series approach above. (I won't give the details of the dynamic programming approach, leaving them to you.)
In order to count the number of unique strings up to reversion, we will count the number of symmetric solutions (i.e. strings whose reverse is the same as the original string). Here is why. Suppose that $A$ is the number of strings, $B$ the number of symmetric strings, and $C$ the number of strings up to reversion. Then
$$ C = \frac{A+B}{2}. $$
(Figure out why on your own.)
How do we count the number of symmetric solutions? Using the same dynamic programming / generating function approach:
$$ (r^2+g^2+b^2)^2(r+g+b) = b^5+b^4 g+b^4 r+2 b^3 g^2+2 b^3 r^2+2 b^2 g^3+2 b^2 g^2 r+2 b^2 g r^2+2 b^2 r^3+b g^4+2 b g^2 r^2+b r^4+g^5+g^4 r+2 g^3 r^2+2 g^2 r^3+g r^4+r^5. $$
Again, we sum the coefficients of monomials $r^ig^jb^k$ with the same constraints as above, and using dynamic programming, we can get a slightly more efficient solution.
