# Combinations of unequal lists

**URL:** <https://boards.straightdope.com/t/combinations-of-unequal-lists/745950>\
**Category:** Factual Questions\
**Created:** [February 12, 2016, 5:13pm UTC](https://boards.straightdope.com/t/combinations-of-unequal-lists/745950 "2016-02-12T17:13:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grey](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@Grey](https://boards.straightdope.com/u/Grey)\
**Post date:** [February 12, 2016, 5:13pm UTC](https://boards.straightdope.com/t/combinations-of-unequal-lists/745950/1 "2016-02-12T17:13:54Z")

</div>

Quick easy question I’m just having a mental block on this.

I have 4 lists of values, but each list is unequal in the number of records. For example:

List 1 : 13 values  
List 2 : 5 values  
List 3 : 9 values  
List 4: 15 values.

How many combinations of List 1:List 2: List 3: List 4 values can I have?

Is it just 13x5x9x15 --\> 8775?

---

<div class="post-metadata">

**Author:** ![Lance\_Turbo](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lance_turbo/32/6156_2.png) [@Lance\_Turbo](https://boards.straightdope.com/u/Lance_Turbo)\
**Post date:** [February 12, 2016, 5:20pm UTC](https://boards.straightdope.com/t/combinations-of-unequal-lists/745950/2 "2016-02-12T17:20:27Z")

</div>

You got it.

See [Cartesian product](http://en.wikipedia.org/wiki/Cartesian_product) for more details.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [February 12, 2016, 5:22pm UTC](https://boards.straightdope.com/t/combinations-of-unequal-lists/745950/3 "2016-02-12T17:22:04Z")

</div>

Your terminology is a little ambiguous but for the obvious interpretation your answer is mostly correct.

If you really mean you want to pick one item from each list, and keep the resulting 4-tuple in the order of [item from list 1, then from list 2, then from list 3, then from list 4] then yes, there are count1 \* count2 \* count3 \* count4 such tuples.

But …

If list 1 has 2 values the same, then two of those resulting tuples will appear to be identical. e.g. if items a and j in list 1 are the same value then tuples (listitem1-a, listitem2-b, listitem3-c, listitem4-d) and (listitem1-j, listitem2-b, listitem3-c, listitem4-d)  
will appear identical.

If list 1 and list 2 both have a value in common that occurs only once in each list, then the good tuple (listitem1-a, listitem2-b, listitem3-c, listitem4-d) will look the same as the defective tuple (listitem2-b, listitem1-a, listitem3-c, listitem4-d)

Whether you care or not about those identical looking tuples is up to you.

---

<div class="post-metadata">

**Author:** ![Grey](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@Grey](https://boards.straightdope.com/u/Grey)\
**Post date:** [February 12, 2016, 8:20pm UTC](https://boards.straightdope.com/t/combinations-of-unequal-lists/745950/4 "2016-02-12T20:20:28Z")

</div>

Thanks folks.
