Suppose we have a string of length N, containing only Xs and Ys, (example of a string of length 5: XYXYX).
How can we calculate the number of strings of length N that do not contain P consecutive Xs ( P <= N) ?
I found this in a programming problem, and I wonder if it can be solved mathematically, I found the answer for a pretty similar problem here in Stack Exchange, about a bit string that does not contain 2 adjacent 0s, but I can't find the tip to adjust it to my problem, could anyone help me with this? Thank you !!!
I would tackle this question using symbolic dynamics, and in particular subshifts of finite type. The shift of finite type $X_{\mathcal{F}}$ over alphabet $\mathcal{A} = \{X,Y\}$ with set of forbidden words $\mathcal{F} = \{\underbrace{XX \cdots XX}_{P\text{ times}}\}$ is what you want to consider.
Form the associated transition matrix to this SFT $M$ and then calculate $M^N$. This matrix encodes the number of length-$N$ words in $X_{\mathcal{F}}$, with the entry $M^N_{i,j}$ being the number of length-$N$ words that begin with $i$ and end with $j$. Hence, taking the total sum of entries $p(N) = \sum_{i,j} M^N_{i,j}$ is the value you're looking for.
The sequence of integers $p(N)$ is known as the complexity function of the subshift.