# How many cyclical binary strings with $O$ ones and $Z$ zeros avoid $N$ consecutive ones?

Given a cyclical binary string $S$ (i.e., the first and last elements are considered adjacent) with $O$ ones and $Z$ zeros, how many of the permutations of $S$ avoid a run of $N$ (or more) consecutive ones?

I've been toying with generating cases and looking at patterns, having come up with polynomials for $N$=$2$ or $3$, but have not been able to discern any pattern to the coefficients yet.

Is there a more direct combinatorial means to get the desired result?

As if often the case with cyclical strings, it is useful to mark the "beginning" of the string of length $n$ (giving a so-called necklace with a clasp). Then, after the mark you may have $k$ alternating blocks of zeros and ones. The zeros are unlimited, so the corresponding generating function is $x+x^2+x^3+\cdots=\frac x{1-x}$. The ones are limited by $\ell=\text{your }N-1$, so the corresponding generating function is $x+x^2+\cdots+x^\ell=x\frac{1-x^\ell}{1-x}$. Then, the your desired numbered of strings following the mark would be $$[x^n]\sum_k\left( \frac x{1-x}\cdot\frac{x(1-x^\ell)}{1-x}\right)^k.$$ Of course, it takes some doing to extract the coefficient of any generating function, but in this case it's very doable. After removing the factor of $x^{2k}$, you're left with a product of $\frac1{(1-x)^{2k}}$ and $(1-x^\ell)^k$, giving rise to a sum of a product of two binomial coefficients.