In how many ways can you put $10$ identical gold coins into four colored boxes so that at least $1$ goes into the blue box, at least $1$ into yellow, at most $2$ into red and at least $3$ into green?
The way I solved this was by writing down all the restrictions, $$B \geq 1, \space G \geq 3, \space Y \geq 1, \space R \leq 2$$ Where each letter corresponds to the first letter of each colour box.
Dividing the problem into 3 cases where there's no coin in red box, 1 coin and 2 coins in red box seems to be the most logical, giving the following results using bars and stars:
C1: R box has zero coins
$\binom{3 + 5-1}{5} = \binom{7}{5}$
C2: R box has one coins
$\binom{3 + 4 - 1}{4} = \binom{6}{4}$
C3: R box has two coins
$\binom{3 + 3 - 1}{3} = \binom{5}{3}$
Giving us a final result of $$\binom{7}{5}+\binom{6}{4}+\binom{5}{3}$$
I wanted to know if this is the correct way of solving a problem like this? What if we had bigger numbers including a box having at most say a 1000 coins, would we need to make a 10000 cases? what if there's multiple at most restrictions? like 2 boxes have to have at most 3 gold coins?
This type of question can be more easily done with generating functions. Say we have some series $a_n$; we can encode $a_n$ as a generating function $\sum_{n=0}^\infty a_nx^n$. The values we want to keep track of are hidden in the generating function as the coefficients of $x^n$. In combinatorics, $a_n$ is used to count the number of ways we can do something to a set of $n$ elements. When you multiply two generating functions, they have a useful combinatorial interpretation.
Consider the product $\sum_{n=0}^\infty a_n\sum_{n=0}^\infty b_n$, where we think of $a_n$ and $b_n$ each as counting ways to do something to a set of $n$ elements. The coefficient of $x^n$ in the product is $\sum_{i=0}^n a_ib_{n-i}$. We can think of this as the number of ways to do what $a_i$ does to $i$ elements in an $n$-element set and do what $b_{n-i}$ does to the other $n-i$ elements in our $n$-element set. Note that we don't choose what $a_i$ acts on or what $b_{n-i}$ acts on, so we say that $a_i$ acts on the first $i$ elements. In the particular case of identical gold coins, it doesn't matter.
I realize that this sounds arcane, so here's an example. Let $b_n$ count the number of ways we can put $n$ coins in the blue box such that we put in at least one. Ignore the other three boxes for now. Then $b_0=0$ (putting in $0$ coins doesn't satisfy the condition of putting in at least one), and $b_i=1$ for all $i\geq 1$. Then the generating function for putting coins into the blue box is $\sum_{n=0}^\infty b_nx^n=x+x^2+x^3+\ldots$ and since $1+x+x^2+\ldots=\frac{1}{1-x}$, we can write the generating function as $\frac{1}{1-x}-1$.
Now let $y_n$ count the number of ways to put $n$ coins into the yellow box such that we put in at least one. The generating function for the yellow box will also be $\frac{1}{1-x}-1$ by the same reasoning. Now consider the product of the generating function for the blue box and the generating function for the yellow box, $(\frac{1}{1-x}-1)^2$. If we look at its series expansion, we see that it's $x^2+2x^3+3x^4+\ldots$. I claim that this is the generating function for putting $n$ coins into the yellow or blue box such that each box gets at least one coin. For $n<2$, we can't satisfy that each box has at least one coin, so there are $0$ ways to do it. For $n\geq 2$, we can put $i$ coins into the blue box, where $1\leq i\leq n-1$, and $n-i$ into the yellow box. Since $i\geq 1$ and $n-i\geq 1$, this satisfies the condition, so there are $n-1$ ways to do this and my claim holds.
To do the full problem, we just need the generating functions for red and green. For red, it's $1+x+x^2$, to show that we can only put in $0, 1$, or $2$ coins. For green, it's $\frac{1}{1-x}-1-x-x^2$, to show that we can't put in $0, 1$, or $2$ coins. Then, if we look at the series expansion of the product of all four generating functions, $(\frac{1}{1-x}-1)^2(1+x+x^2)(\frac{1}{1-x}-1-x-x^2)$, we get $46$ as the coefficient of $x^10$, which is the same as your answer. You can verify that this works for all of the other coefficients listed as well. For a generalized version of this problem, as long as you can find the generating functions for each individual box, which should be easy as long as they're of the form, "at least $n$ coins" or "at most $n$ coins", then you find their product and get the generating function for putting the coins into all of the boxes.