Artificial intelligent assistant

Counting permutations of a multiset restricted by nearness condition I've been scratching the noggin on this for a bit, and have come up blank so far. Given a multiset $S$ with $Z$ zeros and $O$ ones, how many permutations are there where there is at least one pair of ones separated by at most $N$ zeros? E.g., with $S=\\{1, 1, 1, 0, 0, 0, 0, 0, 0\\}$ and $N=2$, $\\{1, 0, 0, 1, 0, 0, 0, 0, 1\\}$ matches the restriction, but $\\{1, 0, 0, 0, 1, 0, 0, 0, 1\\}$ does not. I've looked at the enumeration of smaller cases, searching for a pattern to the counts (some tantalizingly close OEIS hits), but no luck so far. Any ideas/pointers?

Total number of permutations, $P$ = $Z+O\choose Z$.{select the positions for Z Zeroes, positions of One's will get automatically fixed}.

Let $X$ denote the permutaion where all One's are separated by at-least $N+1$ Zeroes. Required answer is $P-X$.

Let $x_i$ denote the number of Zeroes between $i$-th and $i+1$-th $1$, $1\le i\le O-1$. And $x_0$ define number of zeroes before the first one and $x_O $ denote the number of zeroes after the last one. Then by multinomial theorem, $X$ is the number of solutions to the following equation,

$$\sum_{i=0}^O x_i = Z , \ x_0\ge 0,x_O\ge 0 \text{ and remaining } x_i \ge N+1. $$ $$\implies \sum_{i=0}^O x_i = Z-(O-1)(N+1) , \ x_i \ge 0$$

Thus, $X = {Z-((O-1)(N+1)) + O+1 -1 \choose (O+1-1)}$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3583fb734315e5fe8b4a62fa351a2df0