# Creating pairs of homo-, bi- and heterosexual boys and girls

Consider a set of boys and girls. A person can be either homo-, hetero- or bisexual so that they want to be with members of their own gender, the other gender or are indifferent towards gender.

How can I create pairs of these people so that each person wants to be with their partner? Is it possible to easily check if a solution exists?

-
This is a variant of Hall's marriage theorem en.wikipedia.org/wiki/Hall%27s_marriage_theorem You might start there. – Ross Millikan Nov 4 '11 at 13:04
@Ross I think the more conservative members here will object. It will ruin the sanctity of Hall's marriage theorem! – Ragib Zaman Nov 4 '11 at 13:08
@Ragib: I think the more progressive members here will object to the heteronormative restriction of access to this theorem. – joriki Nov 4 '11 at 13:13
Hopefully everyone knows I'm just joking =). – Ragib Zaman Nov 4 '11 at 13:15
@vicvicvic: So, in your model, a heterosexual woman would be happy to marry any man? – Phira Nov 4 '11 at 13:15

1) If the total number is not even, it won't work.

2) If there is an odd number of male homosexuals but no male bisexual, it won't work.

3) If there is an odd number of female homosexuals but no female bisexual, it won't work.

If these problems don't occur, marry off all the homosexuals using possibly one bisexual in either gender.

The remaining even number of heterosexual and bisexual people may have an overhang of one gender. This difference $d$ is even.

4) If there are less than $d$ bisexuals in the more frequent remaining gender, it won't work.

If there are (at least) $d$ bisexuals in the more frequent remaining gender, then marry them off and finally form heterosexual marriages with the rest.

-
I initially misinterpreted "if there are d bisexuals" to mean "exactly d". Thanks for the answer, it works smashingly! – vicvicvic Nov 6 '11 at 19:47
In simple terms: There have to be enough bi's to take care of the homos and heteros that cannot be paired off. – Christian Blatter Nov 6 '11 at 21:13