Q:

Combinatorics Question Regarding Specific Substring of Characters

How many strings of five lowercase letters from the Latin alphabet (containing 23 letters) contain:

a) the letter c?
b) the letters c and d?  
c) the letters c and d in consecutive position with c preceding d and all letters distinct?  
d) the letters c and d, where c is somewhere to the left of d in the string and all letters distinct?  

I have already solved a) using $_5C_1\cdot23^4 =\frac{5!}{1!4!}\cdot23^4$ where one spot is c and the rest are any letter in the Latin alphabet, and b) $_5C_1\cdot_4C_1\cdot23^3 =\frac{5!}{1!4!}\cdot\frac{4!}{1!3!}\cdot23^3$ where one spot is c, one spot is d and the rest are any letter in the Latin alphabet since the letters are not distinct (repetition is allowed).
Now I am confused about how to account for the order of c and d in questions c) and d).  I know that I must now use $\frac{n!}{r!(n-r)!}$ instead of $\frac{(n+r-1)!}{r!(n-1)!}$ since the letters are now distinct, but am lost from there.

A:

Hints:
a) There are $22^5$ words that do not contain the letter c.
b) We count the words that miss c or d or both. There are $22^5$ words that do not contain c, and $22^5$ that do not contain d. But the sum $2\cdot 22^5$ double-counts the words that contain  neither c nor d. So there are $2\cdot 22^5-21^5$ words that are missing c or d or both.
c) The letter c can be in any of $4$ places. Once we have chosen where c is, the location of d is determined. And there are $(21)(20)(19)$ ways to fill the empty spots with letters distinct from c and d and from each other.
d) Put reserved signs on a couple of spots. This can be done in $\binom{5}{2}$ ways. The rest can be filled in $(21)(20)(19)$ ways. 

