There is a fairly systematic way to work this type of question. You were specifically wondering about:
How many 4-letter words can be formed from the letters: ABBCCC?
First, you write the 'source partition' for your word:
[C,B,A]
[3,2,1] <-- this is the `source partition`
Note that the source partition provides for 1 triple, 1 double, and 1 single. Corresponding to that, you write every possible 'target partition' of 4-letters.
[3,1] requests one triple and 1 single
[2,2] requests 2 doubles
[2,1,1] requests one double and 2 singles
For each 'target partition', you write an expression that gives the number of ways that the given target type can occur. An example of the target type [3,1] is:
CCBC # type [3,1]
The expression for that type is:
nCr(1,1)*nCr(2,1) * fac(4)/fac(3)
'nCr( n, r)' is the function for 'combinations', which gives the number of ways you can make a unique selection from n distinct things, taking r at a time. 'fac( n)' is the function for the factorial of n.
Note that source [3,2,1] provides 1 triple, and target [3,1] requests 1 triple. Hence nCr(1,1)
. After the triple is used up, the source [3,2,1] can provide 2 singles, and the target [3,1] requests 1 single. Hence nCr(2,1)
The call to fac(4)
, in each expression, always corresponds to the 4-letter word. Any division, if it occurs in an expression, corresponds to each multiple request of the corresponding target partition. That's all there is to the method, but it isn't always easy to get every last detail correct. The entire computation, as I did it in the programming language Python, follows:
# The `source partition` for the word 'ABBCCC' is:
# [3,2,1]
# # target
w = 0 # ------
w += nCr(1,1)*nCr(2,1) * fac(4)/fac(3) # [3,1]
w += nCr(2,2) * fac(4)/(fac(2)*fac(2)) # [2,2]
w += nCr(2,1)*nCr(2,2) * fac(4)/fac(2) # [2,1,1]
#
# The answer is 38
"How many 5-card hands (from an ordinary deck) have at least one card of each suit?"
First, as a sanity check, a non-GF solution. There must be two cards of one suit and one each of the remaining three suits. There are 4 ways to choose the special suit, $\binom{13}{2}$ ways to choose its two cards, and 13 ways to choose the card from each of the remaining three suits. So the number of hands is
$$4 \cdot \binom{13}{2} \cdot 13^3 = 685,464$$
Now let's try a solution using an ordinary power series generating function. Each suit can contribute 1 to 13 cards, and $n$ cards can be selected from a suit in $\binom{13}{n}$ ways, so the OPSGF is
$$f(x) = \left[ \binom{13}{1}x + \binom{13}{2} x^2 + \binom{13}{3}x^3 + \dots + \binom{13}{13} x^{13} \right]^4$$
The coefficient of $x^n$ is the number of n-card hands. If all we are interested in is the coefficient of $x^5$, we can write
$$f(x) = x^4 \left[ \binom{13}{1} + \binom{13}{2} x + O(x^2) \right]^4 = x^4 \left[ \binom{13}{1}^4 + \binom{4}{1} \binom{13}{1}^3 \binom{13}{2} x +O(x^2) \right]$$
so the coefficient of $x^5$ is $\binom{4}{1} \binom{13}{1}^3 \binom{13}{2}$, in agreement with our previous answer.
Now for the original question: the corresponding exponential generating function is
$$g(x) = \left[ \binom{13}{1}x + \frac{1}{2!} 2! \binom{13}{2} x^2 + \frac{1}{3!} 3! \binom{13}{3}x^3 + \dots + \frac{1}{13!} 13! \binom{13}{13} x^{13} \right]^4$$ which is the same as our OPSGF, because now we are considering the order of the cards in the hand to be significant, and $n$ cards can be selected from 13 in $n! \binom{13}{n}$ ways taking order into account.
The number of n-card hands, considering the order of the cards to be significant, is the coefficient of $\frac{1}{n!} x^n$. If you expand g(x) in the same way as we did for the OPSGF, the coefficient of $\frac{1}{5!} x^5$ is $5! \binom{4}{1} \binom{13}{1}^3 \binom{13}{2}$. But then if you do not want to consider the order of the cards to be significant, we have over-counted, and we must divide by 5! to compensate, leading us back to our original answer. The bottom line is that there is really not much difference between the two approaches, using an OPSGF or an EGF.
Best Answer
Let's only consider the case when there is only one pair of repeated letters, such as VVXYZ.
You're correct to think that VVXYZ has $5!$ configurations with $2!$ repeated letters, so the number of ways of arranging VVXYZ is $\frac{5!}{2!}$.
But we're not just arranging VVXYZ in this example. There are many ways to get one pair of repeated letters, such as AABRC or BBRCD or RRCDA...
So there are 3 possibilities for the double-letter pair (either AA or BB or RR) - that's why you need to multiply by 3.
Then, for each double-letter pair, there are four possibilities (technically, 4C3) for the remaining letters (such as AABRC, AABRD, AABCD, AARCD). That's why you also need to multiply by 4.