Let $S$ be the set of $\{0,1\}$-strings that do not contain $11100$ as a string. Find the generating function of S where the weight of a string is its length.
I tried this way :
Consider all blocks that end with $0$. There are two types of such blocks: $A$ which is either $0$ or $10$, and $B$ which is $1111*0$. (∗ means repeat one or more times).
Now, every sequence of $0$'s and $1$′s can be constructed as $\{A;B\}∗1\,∗$. The resulting sequence does not contain $=11100$ iff two conditions are met: we don't have two consecutive blocks $BA$, i. e. $BA$ is forbidden.
But I am not sure this concept. Please help me.
Thanks your idea.
This answer is based upon the Goulden-Jackson Cluster Method.
According to the paper (p.7) the generating function $f(s)$ is \begin{align*} f(s)=\frac{1}{1-ds-\text{weight}(\mathcal{C})}\tag{1} \end{align*} with $d=|\mathcal{V}|=2$, the size of the alphabet and $\mathcal{C}$ the weight-numerator of bad words with \begin{align*} \text{weight}(\mathcal{C})=\text{weight}(\mathcal{C}[11100]) \end{align*}
The last line was calculated with the help of Wolfram Alpha. The coefficient of $s^6$ for example shows there are $\color{blue}{60}$ valid words of length $6$ from the alphabet $\{0,1\}$ which do not contain the word $11100$. The invalid $2^6-60=4$ words are \begin{align*} \color{blue}{0}11100,\quad \color{blue}{1}11100,\quad 11100\color{blue}{0},\quad 11100\color{blue}{1} \end{align*}