<s>[INST] how to enumerate and index partial permutations with repeats I know how to count permutations of, say, p red balls and q white balls and r blue balls.  I also know how to count permutations of part of a set of distinct objects.  But I don't know an efficient way to count partial permutations with repetition.
To illustrate what I mean: suppose I have a supply of eight As, seven Bs and six Cs, and want to know how many sequences of length 12 can be made from these.  I can do it by adding up the permutations of 8 As and 4 Bs, 8 As and 3 Bs and one C, ... but that's tedious (this example has 45 cases).  Is there a better way?
Finally, is there a procedure to generate the nth such sequence in lexicographic order, without cranking out all of them?
 [/INST] We can count the number of different sequences with the help of exponential generating functions.

Using the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ in a series we can calculate the wanted number of sequences as
\begin{align*}
12!&[z^{12}](1+\frac{z}{1!}+\frac{z^2}{2!}+\cdots+\frac{z^8}{8!})(1+\frac{z}{1!}+\frac{z^2}{2!}+\cdots+\
\frac{z^7}{7!})\\
&\qquad\cdot(1+\frac{z}{1!}+\frac{z^2}{2!}+\cdots+\frac{z^6}{6!})\\
&=484110
\end{align*}
The calculation was done with the help of Wolfram Alpha.

Note: The result coincides with the calculation of @N.F.Taussig. We obtain
\begin{align*}
\binom{12}{8}2^4&+\binom{12}{7}2^5+\binom{12}{6}2^6+\binom{12}{5}\left(2^7-1\right)\\
&+\binom{12}{4}\left[2^8-2\binom{8}{8}-\binom{8}{7}\right]\\
&+\binom{12}{3}\left[2^9-2\binom{9}{9}-2\binom{9}{8}-\binom{9}{7}\right]\\
&+\binom{12}{2}\left[2^{10}-2\binom{10}{10}-2\binom{10}{9}-2\binom{10}{8}-\binom{10}{7}\right]\\
&+\binom{12}{1}\left[\binom{11}{5}+\binom{11}{6}+\binom{11}{7}\right]\\
&+\binom{12}{0}\left[\binom{12}{6}+\binom{12}{7}\right]\\
&=7920+25344+59136+100584+121770\\
&\qquad+100320+52272+15048+1716\\
&=484110
\end{align*}
</s>