# counting number of strings with at least one consonant

The English alphabet contains $$21$$ consonants and $$5$$ vowels. How many strings of $$7$$ lowercase letters of the English alphabet (repeats allowed) contain:

(a) exactly one consonant

(b) exactly two vowels

(c) at least one consonant

(d) at least one vowel and at least one consonant

For (a) I got $$C(21,1) \times C(7,1) \times 5^6$$

For (b) I got $$5^2 \times C(7,2) \times 21^5$$

I have no idea if these are correct. The ones I struggled with are (c) and (d), could someone help me with the last two please?

Edit: After reading the comment by David G. Stork:

For (c), I did $$26^7 - 5^7$$. Since each of the $$7$$ positions can be one of $$26$$ letters, so total number of strings is $$26^7$$, then minus all the strings that does not have a consonant to get the strings that has at least one consonant.

• For (c): Compute the total number of possible strings and subtract the number that have no consonants. Apr 20 '19 at 20:49
• @DavidG.Stork thank you for your response! Are (a) and (b) correct? and do you have any idea how to do (d)? :) Apr 20 '19 at 20:52
• For (a): The lone consonant can appear in one of seven places, and can be one of 21 letters, so there are $7 \cdot 21$ possible specifications. For the remaining $6$ positions, there are $5^6$ possible assignments of vowels. Multiply these two numbers together. For the rest... you're on your own. Good luck! Apr 20 '19 at 21:46
• This tutorial explains how to typeset mathematics on this site. Apr 21 '19 at 10:39
• @N.F.Taussig Thank you for that link, I was trying to figure out how to type in maths format but failed. For (c) I did 26^7 - 5^7. Since each of the 7 positions can be one of 26 letters, so total number of strings is 26^7, then minus all the strings that does not have a consonant to get the strings that has at least one consonant. Is that correct? Apr 21 '19 at 16:36

How many strings of $$7$$ lowercase letters of the English alphabet (repeats allowed) contain at least one vowel and at least one consonant.

The strings that contain at least one vowel and at least one consonant are those that are those not composed only of vowels or only of consonants.

Let $$S$$ denote all strings of $$7$$ lowercase letters.

Let $$V$$ denote all strings of $$7$$ lowercase letters that contain at least one vowel.

Let $$C$$ denote all strings of $$7$$ lowercase letters that contain at least one consonant.

Then we wish to find $$V \cap C$$. To do so, we subtract those strings that contain no consonants or no vowels from the total number of strings.

$$|V \cap C| = |S| - |V^C \cup C^C|$$

If we subtract those strings with no vowels and no consonants from the total number of strings, we will have subtracted those strings with neither vowels nor consonants twice. Since we only want to subtract such strings once, we must add them back. However, it is not possible to form a string of length $$7$$ that contains neither consonants nor vowels. Hence, the answer can be obtained by subtracting the number of strings with no vowels and the number of strings with no consonants from the total. Since there are $$21^7$$ strings with no vowels and $$5^7$$ strings with no consonants, we obtain \begin{align*} |V \cap C| & = |S| - |V^C \cup C^C|\\ & = |S| - (|V^C| + |C^C| - |V^C \cap C^C|)\\ & = |S| - |V^C| - |C^C| + |V^C \cap C^C|\\ & = 26^7 - 21^7 - 5^7 + 0\\ & = 26^7 - 21^7 - 5^7 \end{align*}

• Thank you so much for the taking the time to answer and explain to me the steps as well! I really appreciate it :) Apr 21 '19 at 20:44
• At line 3: |S|−|VC|+|CC|+|VC∩CC| . shouldn't this be |S|−|VC|-|CC|+|VC∩CC| ? Apr 21 '20 at 9:39
• @Garuda Yes, you are correct. Thank you for alerting me to the error. Jun 30 '20 at 22:20