Inspired by this question, it is interesting to know whether it is possible to skip the generation of values ​​containing a specific pattern? For example, there is a sequence of 50 bits, 20 of which 1: 0b10000000000000000000000000000001111111111111111111 (1 bit at the beginning and 19 at the end).

How to create such a generation so that there is no more than 6 consecutive 1-bit and no more than 10 0-bit? In any pattern layout.

Then the first required number in this example will be: 0b10000000010000000000100000000001111101111110111111

and the last 0b11111101111110111111011000000000000000000000000000

That is not sorting after all the busting, but on the fly.

    0