Secret Santa
The riddle
Every year, CJ’s family of five (including CJ) does a book exchange for Christmas. First, each person puts their name in a hat. The hat is shaken, and then each person draws a random name from the hat and gifts that person a book. However, if anyone draws their own name, they all put their names back into the hat and start over.
What is the probability that no one will draw their own name?
Functions and background
I think brute force will work here. Let’s start by denoting each person in the family and generating all permutations of that group.
Results
Now, we just need to count all of the permutations which have at least one element in the same place as the original list of people.
The probability that nobody gets their own name is: 0.3667 or \(\frac{11}{30}\).
Extensions
So it would be nice to know how this probability changes as the number of players in the secret santa game changes. Let’s find out!
EDIT (12/11/2020):
Looking at the solution in next week’s riddler, I see that the probability of nobody getting themselves on a draw is:
\[P_N = \sum_{k=0}^N \frac{\left(-1\right)^k}{k!}\]in the limit as \(N\rightarrow\infty\), we see that this simplifies to:
\[\lim_{N\rightarrow\infty} P_N = \frac{1}{e}\]I will make this the value of the horizontal line on the plot below.
Given what we are observing here, it would seem that the need to re-draw occurs a little more than 1/3 of the time regardless of the size of the group. However, the number of permutations grows quickly \((N!)\), and I won’t be taxing my machine further. There is a steady (slow) growth in the curve, so I won’t rule anything out.
Extension #2: When does the game fail?
If we know the game will fail, which draw is the most likely culprit (we will stick to the \(N=5\) case for this)? First, let’s get only the permutations that fail.
Out of 120 possible drawings, there are 76 failures.
So, if it fails, it is most likely to fail on the first draw. And the first failing draw is distributed as such: