Number of distinct words with at least 2 $a$s, 1 $b$ and 1 $c$

I am trying to find out the number of distinct $n$-lettered words with lowercase letters which have at least 2 $a$s, 1 $b$, and 1 $c$. I could not figure a way to do it. I am unable to eliminate duplicates.

I have gone through Smirnov or Carlitz words. But it didn't help me.


One way to think about solving this problem is taking $n$ blanks, and counting the ways to assign letters to those blanks. As an example, I will be showing how this would be done for $n=6$, but the formulas should apply for all $n$.

So we start with $n$ blanks, and we want to put an "a" in somewhere. Clearly there are $n=6$ ways to do that:

a _ _ _ _ _ / _ a _ _ _ _ / _ _ a _ _ _ / _ _ _ a _ _ / _ _ _ _ a _ / _ _ _ _ _ a

Now note in each case, there are $n-1=5$ blanks left. For the second "a", we thus have $n-1=5$ possibilities: (Suppose we chose the third option before)

a _ a _ _ _ / _ a a _ _ _ / _ _ a a _ _ / _ _ a _ a _ / _ _ a _ _ a

This gives us a total of $n(n-1)=6\cdot 5=30$ options for placing the a's. But you'll notice that for the final word, it doesn't matter whether we place (for example) an a in the first position then third, or third position and then the first. So it turns out we've double-counted each positibility. Accounting for this, we get $n(n-1)/2=6\cdot 5/2=15$.

Now to place the "b", we have $n-2=4$ options:

a b a _ _ _ / a _ a b _ _ / a _ a _ b _ / a _ a _ _ b

And to place the "c", we have $n-3=3$ options:

a c a _ _ b / a _ a c _ b / a _ a _ c b

Now we are up to $n(n-1)(n-2)(n-3)/2=6\cdot5\cdot4\cdot3/2=180$ possibilities for filling the blanks. All that remains is to fill in the unspecified letters. Since these cannot be a, b, or c without disrupting the required counts, we have $23$ options for each of these, and each remaining blank can be filled independently. So we have another $23^{n-4}=23^2$ options.

Our final count is therefore $n(n-1)(n-2)(n-3)23^{n-4}/2=180\cdot23^2$ possibilities.


If you are familiar with factorials, you may have noticed a bit of a pattern developing as we were assigning letters to blanks. In fact, that whole bit can be written in terms of factorials for any sort of letter specifications using the following theorem:

The number of ways to arrange $n$ elements, which come from $k$ groups of $n_i$ indistinguishable elements ($n_1+n_2+\cdots+n_k=n$) is given by:

$$N=\frac{n!}{n_1!n_2!\cdots n_k!}$$

In this specific case, we have $2$ a's ($n_1=2$), $1$ b ($n_2=1$), $1$ c ($n_3=1$), and $n-4$ other letters ($n_4=n-4$). Once we also account for how we can choose the unspecified letters, we get a final answer of:

$$N=\frac{n!}{2\cdot1\cdot1\cdot(n-4)!}23^{n-4}$$

You can confirm that this is equivalent to our previous answer.