Pine script series calculation

a bit puzzle how solve the following issue. I have two series of bool value.

now I know if there are true values within max distance / gap of 4 bars.

example I have folloiwng series

000000000000 1 00000000....
000000000010 0 00000000.....

or of this two will be
000000000010 1 00000000.......

here the gap between two 1 is 2, so how I can plot it or some indication.