Error solving "stars and bars" type problem I have what I thought is a fairly simple problem: Count non-negative integer solutions to the equation
$$x_1 + x_2 + x_3 + x_4 + x_5 = 23$$
such that $0 \leq x_1 \leq 9$.
Not too hard, right? Simply ignore the upper-bound, count the
$$\begin{pmatrix}23 + (5-1) \\ (5-1)\end{pmatrix} = \begin{pmatrix}27 \\ 4\end{pmatrix} = 17550$$ solutions. Subtract from this all (non-negative integer) solutions to the equation
$$y_1 + 10 + x_2 + x_3 + x_4 + x_5 = 23,$$
and there are $\begin{pmatrix}17 \\ 4\end{pmatrix} = 2380$ of these "bad" solutions we shouldn't have counted earlier, but did. Thus we find $17550 - 2380 = 15170$ solutions.
Since this is a prohibitively large number of solutions to check by hand, I wrote a simple Python program to verify whether this answer is correct. It does indeed say there are $17550$ solutions without upper bounds, and $2380$ solutions to the equation for counting "bad" solutions.
However, when I ask it throw away all solutions to the non-upper-bounded problem for which $x_1 \geq 10$, it tells me it's found $15730$ solutions.
My question is: do I not understand the combinatorial calculation so that there are not actually $\begin{pmatrix}27\\4\end{pmatrix}-\begin{pmatrix}17\\4\end{pmatrix}$ solutions, or have I made some kind of programming mistake? Of course, both are also possible.

Your method is correct, there are 15170 solutions. It seems like your python script is doing something wrong at the end.
I wrote a C++ program myself to confirm this:
#include <stdio.h>

int main()
{
   int a,b,c,d,e,sum=0;

   for (a=0; a<10; a++)
   for (b=0; b<24; b++)
   for (c=0; c<24; c++)
   for (d=0; d<24; d++)
   for (e=0; e<24; e++)
   {
     if (a+b+c+d+e == 23)
       sum++;
   }

   printf("sum=%d",sum);
}

And it prints out sum=15170.
