Finding number of solutions for $x+y+z=7$ is given by $$\binom{n-1}{r-1}$$
Here $n=7$, $r=3$
But how to solve when constraints are given like each of $x$, $y$ and $z$ should not exceed a value of $3$?
Finding number of solutions for $x+y+z=7$ is given by $$\binom{n-1}{r-1}$$
Here $n=7$, $r=3$
But how to solve when constraints are given like each of $x$, $y$ and $z$ should not exceed a value of $3$?
HINT:
Let $3-x=X\implies X\ge0$ etc.
$$X+Y+Z=9-7=2$$
So, if $X=0,Y+Z=2\implies Y=2-Z\ge0\implies0\le Z\le2$
What if $X=1,2?$
I assume that you want positive integral solutions of the given equation
Hint :
You need to find coefficient of $x^7$ in the following expression $$(x^1+x^2+x^3)(x^1+x^2+x^3)(x^1+x^2+x^3)$$
That is coefficient of $x^7$ in $(x+x^2+x^3)^3$.
$x,y,z\leq3$ implies $x\leq0$ is impossible $($ think $(0,3,3))$. Then sum is $(1,1,1)+4$, and combination of distribute 4 is only combinations of $(0,2,2),(1,1,2)$.
The formula you stated gives the number of solutions of the equation $$x_1 + x_2 + x_3 + \cdots + x_r = n$$ in the positive integers. Therefore, I will assume that you wish to find the number of solutions of the equation $$x + y + z = 7 \tag{1}$$ in the positive integers subject to the constraints that $x, y, z \leq 3$.
If there were no constraints, the number of solutions would be
$$\binom{7 - 1}{3 - 1} = \binom{6}{2}$$
as you stated.
From these, we must exclude those solutions in which one of the variables exceeds $3$. Observe that at most one of the variables can exceed $3$ since $2 \cdot 4 = 8 > 7$.
Observe that if $x > 3$, then $x' = x - 3$ is a positive integer. Substituting $x' + 3$ for $x$ in equation 1 yields \begin{align*} x' + 3 + y + z & = 7\\ x' + y + z & = 4 \tag{2} \end{align*} Equation 2 is an equation in the positive integers with $$\binom{4 - 1}{3 - 1} = \binom{3}{2}$$ solutions. By symmetry, there are the same number of solutions of equation 1 in which $y > 3$ or $z > 3$. Hence, the number of solutions of equation 1 in which none of the variables exceeds $3$ is
$$\binom{6}{2} - \binom{3}{1}\binom{3}{2}$$
We can solve this problem using generating functions. Note that $$ (x^1+x^2+x^3)^3 =\left(\frac{x(1-x^3)}{1-x}\right)^3 =\frac{x^3}{(1-x)^3}(1-3x^3+3x^6-x^9)\tag{1}$$ where in the last step we used the binomial theorem. We want the coefficient of $x^7$ in (1). Use the identity $$ \frac{1}{(1-x)^k}=\sum_{n=0}^\infty \binom{k+n-1}{k-1}x^n\tag{2} $$ (which can be obtained by repeatedly differentiating the geometric series) where $k\geq 1$ to get that $$ [x^n]\left(\frac{1}{(1-x)^3}\right)=\binom{n+2}{2}\tag{3} $$ and hence $$ [x^n]\left(\frac{x^3}{(1-x)^2}\right)=\binom{n+2-3}{2}=\binom{n-1}{2}.\tag{4} $$ where $[x^n]$ extracts the coefficent of $x^n$ in the generating function. By (1) and (4), it follows that $$ \begin{align} [x^7]\left[\frac{x^3}{(1-x)^3}(1-3x^3+3x^6-x^9)\right] &=\binom{7-1}{2}-3\binom{7-3-1}{2}+3\binom{7-6-1}{2}\\ &=\color{blue}{\binom{6}{2}-3\binom{3}{2}}. \end{align} $$