I have a list like this [1]:
[['a1', 'b1', 'c1'], ['a1', 'b1', 'c2'], ['a1', 'b1', 'c3'],
['a1', 'b2', 'c1'], ['a1', 'b2', 'c2'], ['a1', 'b2', 'c3'],
['a1', 'b3', 'c1'], ['a1', 'b3', 'c2'], ['a1', 'b3', 'c3'],
['a2', 'b1', 'c1'], ['a2', 'b1', 'c2'], ['a2', 'b1', 'c3'],
['a2', 'b2', 'c1'], ['a2', 'b2', 'c2'], ['a2', 'b2', 'c3'],
['a2', 'b3', 'c1'], ['a2', 'b3', 'c2'], ['a2', 'b3', 'c3'],
['a3', 'b1', 'c1'], ['a3', 'b1', 'c2'], ['a3', 'b1', 'c3'],
['a3', 'b2', 'c1'], ['a3', 'b2', 'c2'], ['a3', 'b2', 'c3'],
['a3', 'b3', 'c1'], ['a3', 'b3', 'c2'], ['a3', 'b3', 'c3']]
And one like this [2]:
[['a1', 'b1'], ['a2', 'b2']]
And I want to remove sublists of [1] which contain ALL elements in EITHER sublist of [2]. In other words, if a sublist of [1] contains 'a1' and 'b1'
or 'a2' and 'b2'
, it should be removed (only for full matches of the strings).
List [1] should look like this:
[['a1', 'b2', 'c1'], ['a1', 'b2', 'c2'], ['a1', 'b2', 'c3'],
['a1', 'b3', 'c1'], ['a1', 'b3', 'c2'], ['a1', 'b3', 'c3'],
['a2', 'b1', 'c1'], ['a2', 'b1', 'c2'], ['a2', 'b1', 'c3'],
['a2', 'b3', 'c1'], ['a2', 'b3', 'c2'], ['a2', 'b3', 'c3'],
['a3', 'b1', 'c1'], ['a3', 'b1', 'c2'], ['a3', 'b1', 'c3'],
['a3', 'b2', 'c1'], ['a3', 'b2', 'c2'], ['a3', 'b2', 'c3'],
['a3', 'b3', 'c1'], ['a3', 'b3', 'c2'], ['a3', 'b3', 'c3']]
I've tried a similar method to this:
https://stackoverflow.com/a/17934810/6278576
However, I can't figure out how to adapt it to remove sublists from a list when several criteria are met.
How can this be done?