How to find permutations of specific sets of data

335 Views Asked by At

As said in the title I have this set of data:

A1 A2 A3 B1 B2 B3 B4 C1 C2 D1 D2 D3 D4 D5

I want to find all permutations of combinations like so:

A1 B3 C2 D5 or A2 B1 C1 D5

etc..

I am trying to do this programmatically and can't find a formula for something like this.

2

There are 2 best solutions below

0
On BEST ANSWER

Think about this with just A1, A2, and B1, B2, and B3.

The following are the 6 ways to arrange them:

  1. A1, B1

  2. A1, B2

  3. A1, B3

  4. A2, B1

  5. A2, B2

  6. A2, B3

Therefore, there are $2*3=6$ ways to arrange them. Now, think about the big picture, as in your question. 3 A terms, 4 B terms, 2 C terms, and 5 D terms. What do you do with them?

Spoiler:

$3*4*2*5=120$ ways to arrange the set of data

This is also known as the Fundamental Counting Principle.

0
On

What you are looking for is combinations of

  • one entry from $3$ possiblities listed on the A list,

  • one entry from $4$ possibilities listed on the B list,

  • one from the $2$ possibilities listed on the C list, and

  • one from $5$ possibilities listed on the D-list.

Using rule of the product: That gives us $3 \times 4\times 2 \times 5 = 120$ possible combinations.

Note, this is precisely what we get when computing $$\binom 31 \cdot \binom 41 \cdot \binom 21 \cdot \binom 51 = 120$$


Now, if you consider, say, $(1) \;(A_1, B_2, C_2, D_3)$ one such choice, you need to decide whether, say, $(D_3, B_2, A_1, C_2)$, which is merely a rearrangement (permutation) of $(1)$ counts as different. If so, you need to multiply $120$ by $4! = 24\;$ to get all permutations of all combinations possible: $120 \times 24$.