Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Splitting a Sequence and counting combinations

Suppose I have a sequence of N numbers a1,a2,...an.
a1 is repeated b1 times
a2 is repeated b2 times.

I want to split the total sequence of N numbers into 2 separate sequences of N/2 numbers where the order does not matter.
The user does not care if they an a1 or an a2 ...or an an.

For example suppose the sequence is   111122223333 which has 12 characters.
I can split it into several sequences of 6 characters  for example

112233
122223
123333


What is the formula for determining how many combinations there are of 6 characters?
Avatar of AlHal2
AlHal2
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

The order does not matter eg 112233 is the same as 332211.
Avatar of aburr
do you have to have at least one of each type?
ie is 222333 aceptable?
Avatar of AlHal2

ASKER

222333 is acceptable.
ASKER CERTIFIED SOLUTION
Avatar of phoffric
phoffric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlHal2

ASKER

I want to do this programmatically.  Is there a formula?
Avatar of AlHal2

ASKER

Thanks.  I'll work on the programming bit myself.
Avatar of phoffric
phoffric

As You can see with even your nice numbers for b's, there are min and Max functions in the above process .
 As you try to generalize , the number of edge cases will grow and you will have to have even more min and Max functions to handle those cases.