Is this considered combinations of combinations?

63 Views Asked by At

Excuse my ignorance but I know so little about the topic that Im not even sure how to phrase my question. Ok, so most online combination generators will create lists of combinations of n length from a given set. What do I need to do if I want to take the result of these combinations and combine them all together.

For example, let's say we're talking about people and I want to create a list of combinations of different sets:

  • gender (male, female)
  • ethnicity (Caucasian, Hispanic, African, Native American, Asian / Pacific Islander, Other)
  • height (short, average, tall)
  • age (0-18, 19-22, 23-40, 41-64, 64+)

What kind of combinatorics are we talking about here and is there an online calculator out there that can generate that list for me?

1

There are 1 best solutions below

0
On

Thanks to everyone for their input, it ended up being extremely useful because, first of all, I learned that what we are talking about is Cartesian products so at least I now know what to Google for more information. Thanks to @JMoravitz for that. And thanks to @Mike Earnest for recommending itertools. I ended up writing this simple Python script to do the work for me:

import itertools

sets = [
   ['male','female'],
   ['white','black','latino','american indian','asian','other'],
   ['short','average','tall'],
   ['0-18','19-22','23-40','41-64','64+']
]
for element in itertools.product(*sets):
    print(element)