[Math] Number of 5 letter words with at least two consecutive letters same

combinatorics

How many 5-letter words have at least two consecutive letters which are the same?

I tried to break this up into the following cases:

2 consecutive letters same: $4*26*1*25^3$

3 consecutive letters same: $3*26*1^2*25^2$

4 consecutive letters same: $2*26*1^3*25$

5 consecutive letters same: $26$

Upon adding these cases I got $1675076$.

However, the proper answer is $1725126$ and can be attained through complementary counting.

Why did splitting the problem up into cases not work?

Best Answer

Consider for example the first term $(4)(26)(25)^3$. There are is more than one interpretation of the $25^3$. Perhaps the $25^3$ is motivated by "once we have chosen the double, say aa, and where it is, the remaining $3$ slots can be filled in $25^3$ ways with non-a's." Under this interpretation of the $25^3$, we are double-counting some possibilities and failing to count some possibilities.

It double-counts, for example, the word aabbx, and many others.

It fails to count the word aaxay, and many others.

But there is another interpretation of the $25^3$. We are say constructing a word that starts with aa. Then if we want to avoid further doubles, we have $25$ choices for the next letter, and for each choice we have $25$ choices for the next letter, and so on.

This does count aabab, which is good. But it fails to count aabbx. So it is not surprising that we get an undercount. It would be interesting to count the double-double words, and address the same issue with strings of type aaabb. With some care, one should get a correct count.