0

I have the lists:

list_a = set(["A", "B", "C", "D", "E", "F"])
list_b = set(["1", "2", "3", "4", "5", "6"])
list_c = set(["red", "yellow", "blue", "green"])  

I would like to find the total number of possible combinations of these lists (one item per lists)

This is easily possible with smaller lists

import itertools as it

list_set = [list_a, list_b, list_c] 

len(list(it.product(*list_of_unq_vars)))

Which will return the number of combinations.

However for larger lists i run into a memeory error.

Is there a way to calculate the number of possible combinations in this manner without actually creating the combinations themselves (as i have done above)?

Many thanks, J

JDraper
  • 349
  • 2
  • 11

1 Answers1

5

All you need to do is multiply the length of each list to get total number of combinations possible:

tempcomb = 1
for l in list_set:
    tempcomb *= len(l)
print(tempcomb)
Hoog
  • 2,280
  • 1
  • 14
  • 20