[Math] Permutation problem, combining objects from multiple sets

permutations

I've been working on a hobby coding project in my free time and I've run into quite an interesting problem, which I'm not completely sure how to solve. The problem is roughly stated as follows:

There are two sets, set A and set B. Set A contains the numbers from
1-10 inclusive, and set B contains the numbers from 11-20 inclusive.
What are all the ways to uniquely arrange 4 objects from set A and 2 objects from set B, in a linear fashion?

So I'm thinking that this is a permutation problem. P(10,4) is the unique number of ways to pick and arrange four numbers from set A, and P(10,2) is the unique number of ways to pick and arrange two numbers from set B. Now, you need to uniquely combine the four numbers from A, and two numbers to B. So you would need to find the number of unique ways that you can arrange four values from A and two values from B. But how would you combine these values to find the total number of solutions?

I think I'm on the right track to finding the number of total combinations. However, what's more important is that I develop an algorithm to actually be able to list all the different permutations. I understand that this may be unrelated to the Math StackExchange, but I am hoping that someone can help with either of these problems.

Thank you very much!

Best Answer

The number of different arrangements of 4 objects from $A$ and 2 from $B$ is \begin{equation} \binom{10}{4} \times \binom{10}{2} \times (2+4)! \end{equation} which is different from $P(10,4)\times P(10,2)$.

You can divide the algorithm into 2 parts:

  1. find an algorithm that generates all subsets of size up to $m$ from a set of size $n$. Here in your example, $n=10$ and $m=4$ or $2$.

  2. find all permutations of objects in a set of size $n$. Here in your example, $n = 2+4 = 6$.

Related Question