Back Home

Q: How can I set up a random gift exchange that’s different from year to year?

By Posted On

Posted in Interesting

The original question was: I’ve got a large family and we do a yearly gift exchange one person to one person. And I’d like to make a algorithm or something to do random selection without repeating for some time. Each different value of k, from 1 to N-1, will produce a different star and a different gift-giving pattern. When N is prime, or more generally when N and k have no common factors, you’ll hit every dot with a single star. Otherwise, you have to draw a few different stars (specifically, “the greatest common divisor of k and N” different stars).