5

Consider a standard Secret Santa/gift exchange game draw. We have a pool of $n$ people, each of whom is supposed to be assigned another member of the pool to find a gift for, without the recipient knowing whom they've been assigned to. Essentially, we would like to generate a random derangement without leaking too much (or ideally, any) information about it to the participants, beyond the name of the person they're assigned to.

Obviously we could use a trusted third party or online organizer to do this, but that's not much fun to do at a party, so it'd be better if we could use some method that could be implemented by hand, solely by the participants.

While everyone should ideally have an equal chance of getting assigned to everyone else, it's probably okay if our algorithm is nonuniform over cycle types. In fact, it'd be kind of neat if there was a way of doing this that always generated $n$-cycles, since that would also let you play a self-running Assassin game.

There are two obvious algorithms for doing this:

1) Everyone pulls a name out of a hat, and checks to see if they've drawn their own name. If so, everyone puts the names back and starts over.

This works fine (it's essentially the rejection algorithm for generating random derangements), but is kind of tedious. And there's a tendency for it to degenerate into:

2) Everyone pulls a name out of a hat one by one. If you get your own name, put it back and draw again.

This can fail if the last person draws their own name (at which point you'd have to start over from the beginning). It also leaks information. If someone puts their own name back, that means none of their predecessors can have drawn it; in the extreme case, if person $n-1$ puts their own name back, it's guaranteed to be drawn by person $n$. Additionally, it's not actually uniform, as discussed in this answer.

One could also try to implement something like Sattolo's algorithm to get an $n$-cycle, or the algorithm in this paper to get a general derangement, but I haven't been able to come up with a way to do that by hand without leaking information.

Is there any way of doing this that works better than algorithms 1) or 2), at least arguably? (i.e., can be implemented by hand using common household ingredients faster than algorithm 1), and is more uniform and/or less leaky than algorithm 2)?)

Micah
  • 38,108
  • 15
  • 85
  • 133

2 Answers2

10

I recommend you watch The Assassin Problem (James Grime) which deals with exactly this problem. James Grime posed the question to his viewers on his Youtube Channel: SingingBanana and asked for viewer responses to try to come up with an easy to understand and easy to implement solution which avoids the potential for cheating and leaking knowledge.

Their favorite solution was submitted by a user named GrandDizzy and it goes as follows:

$\bullet$ Take a stack of index cards and on each card write a person's name twice (once on the left in blue and once on the right in red)

$\bullet$ Shuffle that deck of index cards face down.

$\bullet$ Take a pair of scissors and cut the cards down the middle(top-down cut with scissors, not like a "cut" in shuffling). What is left are two stacks of cards, one with blue names and one with red names, both in the same order.

$\bullet$ Take the top card from the red stack and move it to the bottom of it's stack.

$\bullet$ Now, you can remove the top card of each stack and staple them together (blue on bottom, red on top)

$\bullet$ Mix these and lay them out. The person takes the stapled set with their name showing, and their target is the person's name which is hidden stapled below theirs.

JMoravitz
  • 79,518
  • Thanks, that's clever. It's mathematically equivalent to a special case of Henning's solution, but it may be easier to actually implement... – Micah Dec 06 '14 at 21:48
7

Here's a simple procedure which is not leaky, but does lead to everyone knowing the cycle structure of the derangement:

  1. We need $n$ pieces of red paper, $n$ pieces of green paper, and $n$ envelopes.

  2. Everyone writes their name on a piece of red paper, and on a piece of green paper, folds the papers securely, and puts them both into an unmarked envelope.

  3. Collect all the envelopes. Shuffle them well.

  4. Arrange the envelope in one or more circles on a table. I suggest one large circle and a few circles with 2 envelopes in them, if you want to create some uncertainty about whether you're mutually santa with someone.

  5. Take each red piece of paper out of its envelope and move it one envelope clockwise. (Be sure to take the previous red paper out of the destination envelope first so they don't get mixed up).

  6. Shuffle all of the envelopes again.

  7. Open the envelopes one by one. For each one unfold the red paper and give the green paper to the person whose name was on the red paper.

  • Thanks, that works nicely. I guess if you wanted to be slightly more neurotic, you could compute a value of "a few" that roughly corresponded to the expected number of transpositions in a random derangement... – Micah Dec 06 '14 at 21:47
  • @Micah: Yes, though it's not obvious to me that "the expected number of transpositions in a random derangement" should necessarily inform the probability one would want to have for being mutually santa with someone. – hmakholm left over Monica Dec 06 '14 at 22:17