<s>[INST] Number of possible values of $4x-z$ if $x+y+z=20$ Given that $x, y,z$ are non negative integers such that $x+y+z=20$. If $S$ is the set of all possible values of $4x-z$.Find $n(S)$.
My try:
By stars and bars number of non negative integer solutions of $x+y+z=20$ is $\binom{22}{2}=210$
Among these $210$ ordered triplets of $(x,y,z)$ we need to find number of possible values taken by $4x-z$.
Obviously the least value taken by $4x-z$ is $-20$ when $x=0,z=20$.
The next value taken by $4x-z$ is $-19$ when $x=0,z=19$ and so on.
So once we fix $x=0$ ,since $z$ varies from $[0,20]$ number of values taken by $4x-z$ is $21$.
But when we fix $x=1$, we get some overlaps. For example when $x=1,z=18$ we have $4x-z=-14$ and this value has already been counted in the previous case when $x=0,z=14$.
So any way to count total number of values taken by $4x-z$ excluding overlaps?
 [/INST] Well the very least $x$ can be is $0$ and if so, you can have $z$ be any value from $0$ to $20$ inclusive (by letting $y = 20-z$). SO all (integer) values from $-20$ to $0$ are possible but no smaller are possible.
Now we just have to find all possible positive values.
Every positive integer is a multiple of $4$ minus either $0, 1,2$ or $3$ so if we set $z= 0,1,2$ or $3$ we can get set $x$ to any value from $1$ to $17$ (by letting $y = 20 - x-z$) so get all values up to $4\cdot 17 - 0= 68$.  So all values between $-20$ to $68$ inclusive are possible.
Now we just have to find all possible higher values.
And we can do those one by one.  If $n = 4x -z > 68$ and $z \ge 0$ then $x > 17$ so as $0\le x \le 20$ we can have $x = 18,19, 20$.
If $x = 18$ then $z = 20 -18 -y = 2-z$ so $z$ can be $0,1$ or $2$.  So that allows $6\cdot 18 - 0,1,2$ or $72,71,70$ but not $69$.
If $x = 19$ then $z =1-y$ and $z$ can be $0$ or $1$ so that allows $76,75$ (but not $74$ or $73$.
And $x = 20$ then $z=0$ and we have $80$ is possible but $79,78,77$ are not.
So the total number is $-20,....1$ and $0$ and $1.... 68$ and then $3$ and $2$ and $1$ more.  For a total of $20 + 1 + 68 + 3+ 2 + 1= 95$ values.
=====
Or more systematic.
$x$ con range from $0$ to $20$ and $z$ from $0$ to $20$ so $4x-z$ can run from $4\cdot 0 -20=-20$ to $4\cdot 20 - 0=80$
The times $n = 4a - b$ are not possible is if $a + b>20$
As $4a - b= 4(a+1)- (b+4)$ so if we have $n$ not possible so $a + b > 20$ we must also have either $(a+1)+(b-4)>20$ or $a+1 > 20$ or $b-4 < 0$.  So wolog we can assume that if $n=4a-b$ is impossible that we are assuming that $0\le b < 4$. And therefore $a+ b >20$ and $a > 20-b$.
For $a=20$ there are $3$ impossible values values for $b$.  For $a = 19$ there are $2$ impossible values.  For $a=18$ there is $1$. ANd for $a \le 17$ there are none.
So all values between $-20...,80$ are possible except for $1+2+3 = 6$ impossible values.
So there are $101-6 = 95$ possible values.
</s>