TITLE: Number of solutions using partitions for linear equation having restrictions
QUESTION [0 upvotes]: Here is a linear equation $$a+b+c+d=12$$ where $a,b,c,d$ are restricted to be greater than zero and less than or equal to 6.
How many set of positive integer solutions are possible using partitions and permutations?

REPLY [1 votes]: I wrote up a proof using generating functions, but after your comment that you didn't know them, I realized that they were unnecessary. I didn't want to waste the writing, so I left it, but feel free to ignore it. The first two paragraphs use only basic combinatorics.
We know how to find compositions of $n$ into $k$ nonnegative parts- ${n+k-1\choose k-1}$. If we assume each part is positive, we can put $1$ in each part and get back to the same case. In other words, the number of compositions of $n$ into $k$ positive parts is equal to the number of compositions of $n-k$ into $k$ nonnegative parts. Here, compositions of $12$ into $4$ positive parts are the same as compositions of $8$ into $4$ nonnegative parts, since we just put $1$ in each part. This gives us ${11\choose 3}$ ways to get $12$ with $4$ positive parts.
However, a part also cannot be greater than $6$, so we want to remove these parts. The number of "bad" compositions can be found by putting $7$ into one of the parts and $1$ into the rest. In other words, we assume that a part is bad at the start. Then there are $2$ stars left and still $3$ bars, so there are ${5\choose 3}$ ways to add in the last $2$ stars. However, there are $4$ different ways to choose which part is the "bad" part, since it can be any of the $4$. Hence, there are $4{5\choose 3}$ bad compositions. Hence, the difference ${11\choose 3}-4{5\choose 3}$ is the number of good compositions. Note that I can only have one "bad" part, thanks to the nice choice of numbers in this problem. If I had $13$ stars, there could be $2$ bad parts, and I'd be double counting when I take them out.
Consider the function $f(x)=x+x^2+x^3+x^4+x^5+x^6=x(1+x+x^2+...x^5)=x\frac{1-x^6}{1-x}$. The coefficient of $x^n$ of this function is the number of ways each block in this composition can have value $n$. In other words, a part can be anywhere from $1$ to $6$, and in only one way, but nothing else. Then the coefficient of $x^{12}$ in $f^4(x)$ is the number of ways to get a composition of $12$, since this counts compositions into $4$ parts where each part is from $1$ to $6$.
{"set_name": "stack_exchange", "score": 0, "question_id": 2165551}