Number of solutions to equation $a+b+c+d+e+f+g=18$ in $\mathbb{N}$ with restrictions How do you solve the problem:
$a+b+c+d+e+f+g=18$
such that no 2 variables differ by more than 1?
So far I have found that the number of possible solutions $a,b,c,d,e,f,g$ in total are $\binom{24}{6}$, but that does not take into account the restrictions.
 A: $\underline{HINT:}$
If you look at the restrictions, $2\times7 = 14,\;$and $\;3\times 7 = 21$,
so you need to put the restriction $2\le a,b,c,d,e,f,g \le 3$ before solving.
Put $2$ for each variable, and then compute in how many ways you can put the extra $1's$
A: It has to be all $2$'s and $3$'s, or else it won't add up...  you can do $3333222$.  Up to permutations,  this is the only way...  So, ${7 \choose 4 }=35$...
A: I assume you are looking for integer solutions, otherwise there will be infinitely many possibilities.  If no two variables differ by more than $1$, there are two possibilities.


*

*All variables have the same value $x$.  Then $7x=18$ which is impossible.

*Some variables, say $n$ of them, have the value $x$, and the remaining $7-n$ have the value $x+1$.  Then
$$nx+(7-n)(x+1)=18$$
which simplifies to
$$7x=11+n\ .$$
Since $n$ must be an integer from $0$ to $7$, the only solution is $n=3$, $x=2$.  So $3$ of the variables will have the value $2$, the others will have the value $3$, and to count the number of solutions you just have to choose which $3$ of the $7$ variables have the value $2$.  The answer is $C(7,3)=35$.

