How many sequences of s and s of length are there that begin with a , end with a , contain no two consecutive s, and contain no three consecutive s?
- A)
- B)
- C)
- D)
- E)
Answer
C
Key insight
Past the leading 0, the string is k blocks of 10 or 110; the length equation 1 + 2k + j = 19 makes the count a sum of binomials.
Solution
Between consecutive s there must be at least one (no ) and at most two (no ). So after the initial , the string is a sequence of blocks, each either or .
Suppose there are blocks, of which are . The length is
Since , we need . For each , choose which of the blocks are the long ones:
| 6 | 6 | 1 |
| 7 | 4 | 35 |
| 8 | 2 | 28 |
| 9 | 0 | 1 |
Total: .
The answer is .
Why this works
Adjacency restrictions on a binary string translate into a small alphabet of allowed blocks; the string becomes a word over that alphabet, and counting words of a given total length is a binomial-coefficient sum (a composition of into parts and ). Whenever "no two consecutive" and "no three consecutive" appear together, look for a block decomposition before setting up a recurrence.
Alternative approach
Let be the number of valid strings of length . Removing the final or gives , with , , . Then , so .
The trap
Writing the recurrence as Fibonacci (a_n = a_{n-1} + a_{n-2}) and getting a wrong count, or forgetting the block '110' and allowing '1110'.
Common mistakes
- Writing the recurrence as Fibonacci (a_n = a_{n-1} + a_{n-2}) and getting a wrong count, or forgetting the block '110' and allowing '1110'.
- Off-by-one in the length equation (using instead of accounting for the leading ), which shifts the binomial sums and gives or .
Techniques
Map the objects to something easier to count · Split into exhaustive cases and handle each