Number of combinations between two people

45 Views Asked by At

I trying to find an algorithm that will give me the total number of unique combinations of a sequence of numbers between two people.

If I have the following numbers: 1,3,3,3.

Then this can be split in 2 ways between two people:

Person 1 Person 2
1,3.........3 3
3,3.........1 3

There are 2 combinations here.

Likewise, if I have the following numbers: 1,1,2,2.

Then this can be split in the following ways:

Person 1 Person 2
1,1.........2,2
1,2.........1,2
2,2.........1,1

There are 3 combinations here.

I tried using the following formula

(n+r-1)! / r!(n-1)!

where n is the number of distinct numbers and r is the size of the combinations.

That didn't give me the right answer.

Can anyone help?