What is the most efficient way to generate only those binary strings of length n, which have a maximum of k consecutive zeroes.
For eg :- if n = 3, k = 2:
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
and not 000
Note : I need this method for my research (NLP), where I am using bit strings to generate sentences with all possible n-grams. I have tried enumerating all the binary strings, however, since the number of binary strings is exponential in the length of the sentence 2^(n-1), the code is crashing if n > 30. Hence, I am limited to only generating those bit-strings with the above condition for computational feasibility.