Combinations of pieces of pizza with multiple rules This is a question I had to code in python but I dont understand exactly how it works. Is there some way to show the combinations?
Phillip the pizza banker wants to buy some pizza.
He wishes to purchase 23 pieces of pizza, and the available flavours are pineapple, pepperoni and cabanossi. The only restrictions on the combination of pizza pieces that can be purchased are that the number of pieces of pineapple pizza must be a multiple of 3, and the number of pieces of cabanossi pizza cannot exceed 12. In how many ways can Phillip the pizza banker purchase 23 pieces of pizza?
 A: It's probably simplest to split up the possibilities according to how many slices of pineapple there are. If there are $3k$ slices of pineapple then there are $23-3k$ slices remaining. If $23-3k\leq 12$ then he can have from $0$ to $23-3k$ cabanossi (so $23-3k+1$ possibilities), whereas if $23-3k>12$ then he can have from $0$ to $12$ cabanossi ($13$ possibilities).
The possible values for $23-3k$ are just the numbers $1$ less than a multiple of $3$, i.e. $2,5,8,11,14,17,20,23$, and these contribute $3,6,9,12,13,13,13,13$ ways respectively. So the answer is $82$.
A: If he buys $3$ pineapple then he can buy one of the number from the set =$\{0,1,2,3,4,5,6,7,8,9,10,11,12\}$ for cabinossi , hence there are $13$ ways for $3$ pineapple
Similarly $13$ ways are for $\{3, 6,9\}$  pineapple
But for $12 $ pineapple, you cannot buy $12$ cabinossi, so there are $12$ ways 
Similarly for $\{15,18,21\}$ pineapples, you have $\{9,6,3\}$ ways 
So total ways$ 39+12+9+6+3=69 $ ways 
If you count $ 0$ as multiple of $ 3,$ then there are $69+13=82 $ ways
A: You want to find all $(x,y,z)$ such that
$$3x+y+z=23$$
$$y\leq 12$$
$$x,y,z \in \mathbb{N}_0$$
So the number of combinations is the number of integer points on the above plane. 
For $x\in \{0,1,2,3\}$ there are $13$ possible $y$-values such that $z\in \mathbb{N}_0$ and the equation is satisfied.
For $x\in \{4,5,6,7\}$ there are $12, 9, 6 $ and $3$ possible $y$-values such that $z\in\mathbb{N}_0$ and equation is satisfied.
So in total there are $$4\cdot13+12+9+6+3=82$$
possibilities.
