My friend and I are working through a collection of probability questions to practice. We came across the following question. After some work we were able to find two methods of solving the problem, but both of the solutions were pretty clunky.
Based on the source, we believe there is a relatively straight forward and elegant solution to this question, but we can't find it. What is it?
For the purposes of this puzzle, a "string" means a sequences of zeros and ones, e.g. 1011.
Consider all the different strings of length eight — a good first step would be to figure out how many of these exist.
If you pick a length-eight string uniformly at random, what's the probability that it contains two (or more) consecutive 1s?
I will post our two solutions in an answer below but not select it as the actual answer.
Your second approach can be improved. In the first case, a string begins with $1$, and the possible choices for the remaining $7$ bits can enumerated as you have already done, thus $21$ strings that begin with $1$ with no two consecutive $1$s. In the second case, a string begins with $0$, and you must count the ways to arrange $A$ and $B$ to form an $8$-bit string. There are: $$\binom{8}{0} = 1 \quad \text{way to choose no } B \\ \binom{7}{1} = 7 \quad \text{ways to choose one } B \\ \binom{6}{2} = 15 \quad \text{ways to choose two } B \text{s} \\ \binom{5}{3} = 10 \quad \text{ways to choose three } B \text{s, and} \\ \binom{4}{4} = 1 \quad \text{way to choose four } B \text{s.}$$ In fact, you can see that the number of $n$-bit strings that can be created is simply $$S(n) = \sum_{k=0}^{\lfloor n/2 \rfloor} \binom{n-k}{k}.$$ So you can also get the result for $7$-bit strings by computing $$\binom{7}{0} + \binom{6}{1} + \binom{5}{2} + \binom{4}{3} = 21.$$ For the $8$-bit strings, you get $34$, thus the total number of such strings is $55$, and the complement is simply $256-55 = 201$, and the desired probability is $$\frac{201}{256}$$ as claimed, and we can immediately generalize to compute the total number of $n$-bit strings that contain at least one pair of consecutive $1$s as $$P(n) = 2^n - S(n) - S(n-1)$$ where $S$ is the sum given above.
In case the enumeration via binomial coefficients is not clear, let's break it down by looking at a specific example. Say you have a $13$-bit string, and you want to use $3$ pairs of bits of type $B$, which means you'd need to use $7$ single bits of type $A$, and you want to make a $10$-letter string of $A$s and $B$s from these. Clearly, you can choose $\binom{10}{3}$ distinct positions in the string to place the $B$s.
In general, if you use $k$ pairs, that takes $2k$ bits, so you can only use $n - 2k$ bits of type $A$, and in total, you'd have a lettered string of length $n - 2k + k = n-k$ made of $A$ and $B$s. So now you have a string of $n-k$ letters, for which there are $\binom{n-k}{k}$ ways to choose the positions of the $B$s.