Five-letter words from A-Z with constraints

Find the number of five-letter words that use letters from the alphabet $\{A, B, . . . , Z\}$ in which every sequence of three consecutive letters includes three different letters.

First, what does the sentence "in which every sequence of three consecutive letters includes three different letters" mean?

Second, how can I solve this question?

"in which every sequence of three consecutive letters includes three different letters" means, that in word $a_1a_2a_3a_4a_5$ we have:

• $a_1, a_2$ and $a_3$ are three different characters
• $a_2, a_3$ and $a_4$ are three different characters
• $a_3, a_4$ and $a_5$ are three different characters

For example words XDMNG, PRSTP ABCAW are ok (these satisfies all three conditions), but words ABACD, XYZYA, UMBGB, ABWWX are not ok.

HINT

• $a_1$ can be chosen in any way
• $a_2$ is different from $a_1$
• $a_3$ is different from $a_1$ and $a_2$
• $a_4$ is different from $a_2$ and $a_3$
• $a_5$ is different from $a_3$ and $a_4$

Let $X_1X_2X_3X_4 X_5$ be such a word then $X_1,X_2,X_3$ are all different letters, $X_2,X_3,X_4$ are all different, and $X_3,X_4,X_5$ are all different.

Now we can choose $X_1$ in 26 ways, $X_2$ in 25 ways ($X_2$ is different from $X_1$), and $X_3$ in 24 ways ($X_3$ is different from $X_1$ and $X_2$).

What about $X_4$ and $X_5$?

The condition means that 'ABCAB' is a valid word, but 'ABCAC' is not, because the three consecutive letters 'CAC' contain only two different letters.

The solution is actually quite simple. For the first letter, we have 26 choices. For the second, only 25 because we can't reuse the first letter. For the third, we have 24 choices. For the fourth, we have again 24 choices (because now we can reuse the first letter). The fifth: again 24 choices.

So it's

$$26 \times 25 \times 24^3 = 8985600$$

(hover over the box above to show the solution)

To form a 5-letter word, you need to fill 5 places.

First place: You can use all 26 alphabet

Second place: You can use 25 alphabets as you can't use the previous one.

Third place: Because you have a 3-letter rule, you can't use both the previous letters, hence just 24 choices here.

Fourth: Again 24 letters here(can't use those at 2nd and third place)

Fifth: Again 24 letters.

Hence, you have $26*25*24^3$ 5-letter word under these conditions.