In a simplified form, the problem is as follows: there are a large number of patterns of zeros and ones. Possible * symbol at the end of the template. (For example: 1, 10, 1011 *)
And there are a large number of lines. For each line, you need to check whether the line is "covered" with any of the patterns.
Question: how to do it most effectively? Surely there is some known algorithm or data structure for this task.