Given a natural number $n$. How many partitions into three parts $a+b+c=n$ are there with the additional restriction that $b+2c=k$.
E.g. for $n=12,k=18$ I get four partitions $(a,b,c)$: $(3,0,9),(2,2,8),(1,4,7),(0,6,6)$.
How to count'em in general?
Given a natural number $n$. How many partitions into three parts $a+b+c=n$ are there with the additional restriction that $b+2c=k$.
E.g. for $n=12,k=18$ I get four partitions $(a,b,c)$: $(3,0,9),(2,2,8),(1,4,7),(0,6,6)$.
How to count'em in general?
Le we choose $c$ first. $c$ may range from $0$ to $\left\lfloor\frac{k}{2}\right\rfloor$, hence we have $\color{red}{1+\left\lfloor\frac{k}{2}\right\rfloor}$ choices.
That choice fixes the value of $b$ (as $k-2c$); once we have the value of $b$, the value of $a$ is fixed, too, as $n-b-c = n-k+c$. If $k\leq n$, the previous choices all lead to a valid triple $(a,b,c)$. Otherwise, we have to discard those triples in which the value of $c$ is smaller than $k-n$. At last we have that the number of solutions is given by: $$\color{red}{ 1+\left\lfloor\frac{k}{2}\right\rfloor-\max(0,k-n)}.$$