Sunday, November 23, 2025

A five person class! That's deranged!

You are participating in a holiday gift exchange with your classmates. You each write down your own name on a slip of paper and fold it up. Then, all the students place their names into a single hat. Next, students pull a random name from the hat, one at a time. If at any point someone pulls their own name from the hat, the whole class starts over, with everyone returning the names to the hat.

Once the whole process is complete, each student purchases a gift for the classmate whose name they pulled. Gifts are handed out at a big holiday party at the end of the year. At this party, you observe that there are “loops” of gift-giving within the class. For example, student A might have gotten a gift for B, who got a gift for C, who got a gift for D, who got a gift for A. In this case, A, B, C and D would form a loop of length four. Another way to have a loop of length four is if student A got a gift for C, who got a gift for B, who got a gift for D, who got a gift for A. And of course, there are other ways.

If there are a total of five students in the class, how likely is it that they form a single loop that includes the entire class?

For this particular case, we can just go through all of the possible outcomes. Let's first enumerate all of the possible single loops for all five students. Let's use the permutation notation $(ABCDE)$ stand for the loop where $A \to B \to C \to D \to E \to A.$ It doesn't necessarily matter where on this loop you start, so let's always assume that we start with $A$. Then we are free to choose any ordering of $B,$ $C$, $D,$ and $E$ to form a loops, so there are $4! = 24$ such loops.

On the other hand, since we cannot ever have a one person loop, where a person receives themselves as the giftee, the only other acceptable assingments for our gift exchange is that there is a combination of a 2-loop and a 3-loop. Here we see that there are $\binom{5}{2} = 10$ ways of choosing the two students to be in the 2-loop. By analogy, we see that there are $2 = (3-1)!$ ways of arranging the remaining members of our 3-loop. So there are a total of $\binom{5}{2} 2! = 20$ other acceptable gift exchange assignments.

Therefore, the probability that all of the giftees form a single loop when there are $5$ students is $$\frac{24}{24+20} = \frac{6}{11} = 54.5454545454\dots\%.$$

No comments:

Post a Comment