I read a question recently, asking
In how many ways can $3$ letters be chosen from $AABBBC$?
The solution says 'It is possible to derive a formula that can be applied in all such cases'. However, it does not do so, instead going about a case-based analysis and recommending that the reader do the same.
I am unsure whether said formula was omitted because it is too complicated, or if the writers meant to say 'it is impossible'. So I set about trying to derive such a formula.
My formulation of the question:
Let there be $a_1$ objects of type $1$, $a_2$ of type $2$, and so on, till we have $m$ types of objects, with type $i$ having $a_i$ objects. All objects of the same type are identical, and two objects of different types are different. Find the number of ways $n$ in which $k$ objects can be selected, assuming $k\leq\sum a_i$.
Alternative formulations I thought of:
How many solutions does the equation $x_1+x_2+\dots+x_m=k$ have, where $x_i\in\Bbb N,\;\;0\leq x_i\leq a_i$? (This is similar to this question, except that here the order of the numbers matters and each number has constraints.)
Let $h=x_1+x_2+\dots+x_m$, where $x_i\in\Bbb N,\;\;0\leq x_i\leq a_i$. As each $a_i$ takes all its possible values, how many times does $h=k$?
Let there be an $m$-dimensional space, where a general point has coordinates $(x_1,x_2,\dots,x_m)$. How many lattice points does the part of the $(m-1)$ dimensional space $\sum x_i=k$ contained in the portion of the $m$-dimensional space given by $0\leq x_i\leq a_i$ have?
I tried starting with $m=1$ and proceeding from there.
$\text{WLOG}\quad a_i\leq a_{i+1}$
$m=1$
Then there are $a_1$ identical objects, and there is only $1$ way of choosing $k$ objects, as all are identical.
$m=2$
From here already I run into problems. If $a_1+a_2=k$, then $n=1$. If not, then things get much more complicated. It matters by where $k$ lies with respect to them, and also how they lie with respect to each other.
Here, if $k\leq a_1,a_2$, then $n=k+1$. If $k$ lies between $a_1,a_2$ then $n=a_1+1$.
$m=3$
If $k\leq a_1$, then $n=\frac{(k+1)(k+2)}2$.
If $a_1\leq k\leq a_2$, then $n=\frac{(a_1+1)(2k-a_1+2)}{2}$
If $a_2\leq k\leq a_3$, there are two cases, when $a_1+a_2\leq k$ or $a_1+a_2\geq k$.
It was at this point that I gave up.
Please help.