# Filter a nested list based on conditions on its elements

I have a large ordered list of lists of integers like this

set={{3,4,5,6,7,9},{1,2,3,4,5,6},{3,4,5,6,9,10},{3,4,5,6,11,12},{3,4,6,9,11,12},...}


and I would like to filter out the nested list based on two conditions. The conditions are two types of shorter nested lists

• pairs of consecutive numbers that are not allowed anywhere in the nested list
• pairs of consecutive numbers that must occur somewhere in the list

required={{3,4},{5,6},...}

notallowed={{1,2},{9,10},...}

The output in this case would be

{{3,4,5,6,7,9},{3,4,5,6,11,12}}

• why do you need both notallowed and also allowed? Would not just using notallowed be enought to remove those unwanted? Feb 19, 2018 at 23:45
• No because allowed must be there all present. I can remove all notallowed but that does not guarantee there are all alowed (can be {3,4} but not {5,6}). Feb 20, 2018 at 0:01
• For your use case, what would the maximum integer be? Are the allowed and disallowed sets always pairs of consecutive numbers? Are your sublists always ordered? Feb 20, 2018 at 0:54

You can use SequencePosition -- if it returns a nonempty list, then the given sublist is present:
(

{{3, 4, 5, 6, 7, 9}, {3, 4, 5, 6, 11, 12}}