Inelegant Solution 1
$$
\begin{align}
P = \frac{1}4 + \frac{3}4\times \left( \frac{1}6 + \frac{5}6\times \left( \frac{2}{10}+\frac{8}{10}\times \left( \frac{3}{16}+\frac{13}{16}\times \left( \frac{5}{26} + \frac{21} {26}\times \left(\frac{8}{42} + \frac{34}{42} \times \left( \frac{13}{68} \right) \right)\right)\right)\right)\right)
\end{align}
$$
This gives
$$
P = 0.78515625
$$
We built this equation one section at a time, first considering a string of length two, then of length three, then of length four, etc. At first we assumed every section would have the same co-efficient (1/4) but soon realize that there was a monty-hall-esque selection thing going on, and had to figure out the coefficients one at a time.
Interestingly: the coefficients of each section (1/4, 1/6, 2/10, 3/16, etc.) are Fibonacci sequences in the numerator and denominator. Once we saw that, it was a little easier to quickly figure out the answer.
So, our first equation was:
$$
P(Length_2) = \frac{1}{4}
$$
Then we did a weighted averages function with the probabilities for the string starting in the second slot:
$$
P(Length_3) = \frac{1}{4} + \frac{3}{4} \times ( \frac{1}6 ) )
$$
And then just kept expanding that until we got all eight positions considered:
$$
P(Length_4) = \frac{1}{4} + \frac{3}{4} \times ( \frac{1}6 + \frac{5}6(\frac{2}{10} ) )
$$
etc.
Inelegant Solution 2
Let's count the negative cases and then subtract that number from the total number of possible permutations (i.e. 256).
Define A = 0
and B = 01
With these definitions, we can count the permutation of a string composed of A's and B's and only be counting "failed" matches.
First, imagine all strings of A and B where the binary length is 7
.
AAAAAAA = 1 permutation
AAAAAB = 6 Permutations
AAABB = 10 Permutations
ABBB = 4 Permutations
Since the strings are only of length 7
, we can see that we can put either a 1
or a 0
at the beginning of each string, and given the definitions of A
and B
, all of those will be negative results.
Therefore, we have identified ( 1 + 6 + 10 + 4 ) * 2 = 42 negative results.
However, we missed a set of cases. Negative-result strings in this form: 010XXXXX
are not counted.
We manually brute forced the number of negative-result permutations for the XXXXX
above:
1. 00000
2. 00001
3. 00010
4. 00100
5. 01000
6. 10000
7. 00101
8. 01001
9. 01010
10. 10001
11. 10010
12. 10100
13. 10101
42 + 13 = 55 negative-result cases.
Therefore, the answer is (256-55)/256, or 201 / 256.
$$
P = 201/256\\
P = .78515625
$$