I’m currently working on an application where I take varying size groups of objects and I need to determine all the possible combinations those items can make. I’ve figured out the code to do it because of helper functions. but it’s driving me nuts that I can’t recall the math. It’s been a very long time since I’ve had to do any of this math and I’m having a hard time finding an example like this online. So hoping someone here can lend a hand.
Suppose the scenario that someone is trying to determine how many outfits they can generate from the clothes in their closet. It’s not considered a complete outfit unless they have one of each type of clothing. Given the below items found in the closet.
How many different combinations can be generated. (Assuming they all match. ;-P)
Hats - 3
Ties - 5
Shirts - 8
Gloves - 3
Belt - 3
Pants - 5
Footwear - 2
Using a smaller set as an example:
Hats - 1
Ties - 1
Shirts - 1
Gloves - 1
Belt - 1
Pants - black, blue
Footwear - black, brown
So we end up with 4 outfits.
Hats through gloves always remain the same then it’s just the combination of Pants and Footwear.
1 outfit with black shoes and black pants
1 outfit with black shoes and blue pants
1 outfit with brown shoes and black pants
1 outfit with brown shoes and blue pants
If they have to have one of each then it’s simply the product of each of them, i.e. 3 * 5 * 8 * 3 * 3 * 5 * 2 (i.e. 10800).