Restrictions:
- First and the last digit has to be
1.- Contain no two consecutive
1'sand- Contain no three consecutive
0's
From my observation first two and last two digits will be fixed as 10 and 01, because it can't be 11... or ...11. So we got n-4 places left to fill. Apart from the first 2 and last 2 places if we add one more space then that space can only have 1, not 0. If we add one more place then there are two possible way (100101, 101001). So that's what I got
For
n=6 2 ways
n=7 2 ways
n=8 3 ways
n=9 4 ways
I don't know if I am doing it right or not and what's the easy way to find the number of ways for this scenario rather than counting.
I would appreciate some guidance for a general rule of a binary string of length n that do not contain 3 consecutive 0's and 2 consecutive 1's while starting and ending with 1
I can find a recursive formula, but a general formula is tricky.
$f(x) = f(x-2) + f(x-3)$
That is because the pattern must start with 1, then you must have either one or two 0's before the next 1. In other words, 01 or 001.
Thus any sequence of length X is either (a valid sequence of length x-2 + 01) or (a valid sequence of length x-3 + 001)
For a general formula as a function of N, we can assume
$f(x)=\sum{n^x}$ for some values of a and then
$n^x=n^{x-2}+n^{x-3}$
Leaves $n$ as a root of the cubic equation $y^3-y-1=0$.
Thus $f(x) = a_1n_1^x + a_2n_2^x + a_3n_3^x$, where $n_1, n_2, n_3$ are the roots of the equation $x^3-x-1=0$. But since two of these roots are imaginary, it is a problem to find a specific formula that is non-messy.
In your case, we have
So your calculations are right.
Your problem reminds me of an American Invitational Math Exam problem where you had to find the number of sequences of N coin flips with no 2 tails in a row. You could thus have either H or HT to create a list of length N+1, chopping off the starting H.
Then $g(x)=g(x-1)+g(x-2)$ and if we assume $g(x)=\sum{a^x}$ for some values of $a$, we get $a^n=a^n-1+a^n-2$, or $a^2=a+1$, making $a$ the golden ratio.