This must be basic, but my Mathematica (and overall programming) skill level is too low to find a handy solution:
I need to generate all possible lists of $m$ integers (I call these integers $x_i$'s, where $i=1, \dots, m$, with $0 \leq m \leq X$) such that $$\sum_{i=1}^m x_i = X.$$
For each list generated, I then need to count how many of the $x_i$'s are $0$'s, $1$'s, etc., up to $X$.
I can tell that these $m$ integers will be arranged in the following possible configurations:
$$ \frac{(m+X-1)!}{(m-1)! \ X!}.$$
Also, that for a given $x_i$, there will be the following number of possible configurations: $$\frac{(N+W-x_i-2)!}{(N-2)! (W-x_i)!}.$$
Say, $m=3$ and $X=3$. Then the possible configurations are $$\{3, 0, 0\},$$ $$\{2, 1, 0\},$$ $$\{2, 0, 1\},$$ $$\{1,2,0\},$$ $$\{1,0,2\},$$ $$\{1,1,1\},$$ $$\{0,3,0\},$$ $$\{0,2,1\},$$ $$\{0,1,2\},$$ $$\{0,0,3\}.$$
So, here, there is one 3 and two 0's in the first list, etc.
Now, I need Mathematica to help me generate these lists (10 in my example), but for arbitrary (though not very large) values of $m$ and $X$.
Again, my next step is to make Mathematica take each list in turn and count the $x_i$'s that are zeroes, ones, etc. up to $X$. But that I think I can try and figure out myself.
I did look up similar questions in the archive but couldn't find a pointer to the solution.