# Thread: String counting questions

1. ## String counting questions

There are two parts to this one. They are listed word for word.

1. How many 12 lowercase letter strings are there that contain at least 2 vowels (a vowel is one of {a,e,i,o,u})?
2. How many bit strings
1. of length 12 contain 8 consecutive zeros?
2. are there of length at least 5 and at most 10?
Please show your work.

2. Hello Runty
Originally Posted by Runty
There are two parts to this one. They are listed word for word.

1. How many 12 lowercase letter strings are there that contain at least 2 vowels (a vowel is one of {a,e,i,o,u})?
2. How many bit strings
1. of length 12 contain 8 consecutive zeros?
2. are there of length at least 5 and at most 10?

Please show your work.
1. Assuming that repetition is allowed, there are $\displaystyle 26^{12}$ strings altogether. Of these, there are $\displaystyle 21^{12}$ that contain no vowels.

To construct a string containing exactly one vowel:
there are $\displaystyle 12$ positions in which the vowel might be placed;

there are $\displaystyle 5$ choices of vowel;

there are then $\displaystyle 21^{11}$ choices of consonant for the remaining $\displaystyle 11$ places.
Total: $\displaystyle 12\times5\times21^{11}$

So the number of $\displaystyle 12$ letter strings that contain $\displaystyle 2$ or more vowels is:
$\displaystyle 26^{12}-21^{12} - 12\times5\times21^{11}$
which is quite a lot!

2a. I am assuming this means exactly $\displaystyle 8$ consecutive zeros. So consider the 'block' containing these $\displaystyle 8$ zeros. This is to be positioned along with $\displaystyle 4$ other bits.

If the block is at one end of the bits:
there are two choices of end;

the bit immediately adjacent to the block must be a $\displaystyle 1$;

there are then $\displaystyle 2^3 = 8$ choices of the remaining 3 bits.
Total: $\displaystyle 2\times8 = 16$

If the block of $\displaystyle 8$ zeros is not at one end:
there are $\displaystyle 2$ choices of position for the block;

the bit on either side of the block must be a $\displaystyle 1$;

there are then $\displaystyle 2^2=4$ choices for the remaining two bits.
Total: $\displaystyle 2\times 4 = 8$

So the overall total is $\displaystyle 16+8 = 24$.

2b. There are $\displaystyle 2^n$ bit strings of length $\displaystyle n$. So there are:
$\displaystyle \sum_{n=5}^{10}2^n$
bits strings of length $\displaystyle 5$ to $\displaystyle 10$ inclusive.

I reckon that adds up to $\displaystyle 2016$.

Grandad