Eduardo,
This really isn't a VB question so much as an algorithm question. You may
have better luck in a math oriented user group than in this one. The
language really wont matter once someone comes up with the algorithm. The
logic is the problem here, nto the syntax.
However, I think its an interesting challenge and will give ti some thought
to see if I can come up with an approach.
Anyway... my thoughts so far...
First, you need to know that the women do not outnumber the men by more than
1, or the task is impossible.
next, calculate the total number of possibilities for the order in which the
women (XX) line up by themselves. forget about them standing next to each
other, you will insert the men later.
then calculate the number of ways in which the men (XY) can line up by
themselves.
Now that you have two sets of outcomes, XX and XY, the product of which will
tell you how many possible outcomes you have if all the extra men line up at
the end of the line.
For each extra man you will have XX+1 possible places for the extra man to
stand (they can be in front of any of the women in line, or in the very
back).
This last piece will require a little more thought, but if you have done all
the other algorithms you probably have somethign that will work for this.
Please post your final algorithm, as this is an interesting problem.