The Dirtiest Math Problem Ever (Rated R)

You have been warned. You are allowed to read this if you are 17 or over. Otherwise, you can ask your parents to read this to you. Here is a famous old condom puzzle in the version I heard when I was a teenager myself:

A man hires three prostitutes and wants to have sex with all three of them. They all might have different sexually transmitted diseases and they all want to use condoms. Unluckily, they have only two condoms. Plus, they are in the forest and can’t buy new condoms. Can the man have sex with all three of the women without danger to any of the four?

Everyone in this problem is so health-conscious, that it might not be such a dirty problem after all. I leave you with the fun challenge of figuring this problem out.

Another fun variation of this problem is when you have two men and two women and two condoms. Every woman wants to have sex with every man. How can they do that?

If you are a teacher and want to use these great puzzles for younger students, you can follow the example of MathWorld and pretend that it’s a glove problem between doctors and patients.

Recently my younger son and his MIT friends invented another variation of this problem:

Suppose three gay men all want to have sex with each other and every pair among them wants to do two penetrative sexual acts, switching roles. They want to avoid contaminating each other, and in addition, each man also does not want to cross-contaminate himself from either region to the other. How can they do that using exactly three condoms?

Let me remind you that they plan to perform six sexual acts altogether, meaning that six condoms would be enough. On the other hand, each of them needs two condom surfaces, so they can’t do it with less than three condoms. My son showed to me his solution, but I will postpone its publication.

Of course, you can say that this is a glove problem about three surgeons operating on each other.

In addition, you can generalize it to any number of gay men. Here is my solution for four men and four condoms, where letters denote people, numbers denote condoms, and the order of people represents roles: A12D, B32D, C2D, A14C, B34C, D4C, A1B, B3A, C21B, D41B, C23A, D43A.

Can you solve the problem for five or more people?



  1. Tanya Khovanova:

    Of course, the classical problem provides a nice upper bound for the generalized gay men problem. We can divide gay men into two groups (in an optimal manner) and say that these two groups can be treated as different genders in the classical problem. Then repeat that inside each group.
    But we certainly can improve on that, as for three men the derived upper bound is four, and the real answer as three.

  2. JBL:

    Okay, here’s the classic one (which I had heard before, many years ago, and completely forgotten about since then): our condoms together have 4 sides and we have 4 people, so each person must be assigned exactly one condom side. In particular, our intrepid hero must always be wearing the same side of the same condom. Initially, our fellow puts on both condoms and has intercourse with the first prostitute. He then removes the outer condom and sets it carefully aside, before having intercourse with the second prostitute (wearing only one condom this time). He then takes the outer condom and puts it back on, reversed from its original orientation, in order to have intercourse with the third prostitute.

    We can also ask the problem for an arbitrary number of (heterosexual) men and women. This is some sort of covering or coloring problem (for complete directed graphs in the case of gay men and complete bipartite graphs in the case of men and women), and I suppose we could generalize to any digraph (where an arrow from V to W means we wish to allow V to penetrate W).

  3. misha:

    I vaguely remember a similar theme developed in a different context in part 37 called “Permutation of particles — Are particles like gloves?” of the online physics book at

  4. Tanya Khovanova’s Math Blog » Blog Archive » Gay Polygamy:

    […] about different directions. I recently wrote a piece about condoms. Now I have a new generalization for the classic condom puzzle. Suppose we have a mixed-type […]

  5. Arthur Rainbow:

    You can say I’m dumb, but, I thought about the answer of putting one condom on the other, but dismissed it because of the problem of condom. If you put a condom on top of one other, it seems to really increase the risk they both break.
    (Because there is some kind of motion between the two rubeer)

    But thats right, I’m still trying to find something without rubber to redo the exercice, and I can’t find it.

  6. Tanya Khovanova:


    Mathematicians live in abstractions. They ignore minor details such as practicalities of having two condoms on top of one other. You were on the right track.

  7. tehag:

    Using the “Hasan’s Horses” solutions as an example, the answer is “no.” The condoms only have lube on one side, and so cannot be used inside out. I’m sure I can extend this to exhaustion.

  8. morgan beatch:

    problem one.
    if he can reuse and the man does not have any disease, the third time he can make a new one with both of em so that the faces of two condoms previously in contact with the “man” are the faces that face opposite to each other in new condom.

    problem two.

    the three persons (say A,B,C ) use condoms C!,C2,C3 like
    c1 c2 c3
    A —> B, B —>C ,C —>A

    c2+c3 c3+c1 c1+c2
    A <— B, B <—C ,C <—A

    by c2 + c3 i mean c2 goes into c1 without turning the condoms over(which was necessary in problem 1).

    ps:I hate being smart

  9. morgan old:

    This can be generalized if you think of the primitive set of acts as directed cyclic polygon (a directed edge represents a condom) the path would be the new condom for act between any two pairs

    by path i mean (Ci+Ci+1+…..Cj) (if k>n Ck starts from C1)

    i think tanya will get this. please post if unclear!

  10. morgan old:

    for the first problem
    the new condom is formed by flipping one condom and the other one into it!

  11. szy:

    wait, someone please explain what ‘might’ means here. this is driving me nuts. Do we have a number as in probability or is it just ‘might’ ( in which case it’s perfectly safe to say it could go either way )

  12. Alfredo:

    Proposed solution for 3 men and 3 condoms, where letters denote people, numbers denote condoms, and the order of people represents roles:
    A12B, B21A, A13C, C31A, B23C, C32B

  13. Keith Nuvallie:

    Let’s face it. Sex is a fact of life. But today’s increasing sexual liberation and tolerance have resulted in unconventional practices and encouraged sexual orientations that were once considered taboo to be accepted by quite a number of people. Without passing judgement to those individuals who prefer to experiment in their sexual affairs, this liberal attitude and behavior could lead to serious consequences if parameters to a pleasurable and safe sexual activities are not observed and met. The same is also true with the general public who lacks proper understanding and appreciation of sexual health issues and standards which could lead to neglect of their partners’ sexual rights.^

    Remember to inspect our new web portal

  14. Fedor Duzhin:

    A variation of this problem was offered in Russian Programming Olympiad in 1994 when I was a participant. There were m men and n women and the objective was to write a computer programme to find the minimal number of condoms. The funny thing is that the original solution the organizing committee had come up with contained an error and the problem is probably still open.

    The story was about patients in a clinic with different skin conditions.

Leave a comment