[Math] How many strings of length four that have the letter x in them

combinatoricsdiscrete mathematics

We're only considering lowercase letters, repetition is allowed.

Number of strings of length $4 = 26^4$
Number of strings of length $4$ other than $x = 25^4$
$26^4-25^4 = 66,351$ strings.

This is one solution. But i was thinking of this problem as…

We have $4$ possible positions for $x$. After $x$ is placed, there are $3$ places left. And we have $26^3$ possibilities for those positions.
So, strings that have letter $x = 4\cdot (26^3) = 70304$ strings.

What is wrong with this approach?

Best Answer

You will have to make $4$ cases:-

  1. Only one 'x' : you can place it at any one of the four available places and fill remaining three places with remaining $25$ letters in $4\choose1$$\cdot25^3$ ways.
  2. Two 'x'es : choose two places and then fill remaining two places with any of remaining $25$ letters in $4\choose2$$\cdot25^2$ ways.
  3. Three 'x'es : choose three places and fill remaining one place with any of remaining 25 letters in $4\choose3$$\cdot25^1$ ways.
  4. Four 'x'es : There is only one possible case i.e. xxxx.

So, total number of combinations combinations are, $4\cdot25^3+$$4\choose2$$\cdot25^2+$$4\choose3$$\cdot25^1+1=66351$