Most efficient way to check generate combinations with condition

Viewed 74

In python, itertools offers the method of generating combinations for a given list n and length L. I am looking for the most efficient / quickest way to generate all combinations, which fulfil the condition of not being a superset of a predefined list.

results = []
for combination in itertools.combinations(n, L):
   for item in subset_list:
       if set(combination).issuperset(set(item)):
          continue
       else:
          results.append(combination)

Yet, for large n this might become quite complicated. I am looking for the most efficient way to not generate all combinations in the first place and check upon their conditional success but consider the condition while generating the combinations.

0 Answers
Related