|
This page allows you to "draw names" for a gift exchange in a group of 4 to 18 people, taking into account a given set of restrictions (so that, for example, someone does not get the name of his/her spouse). Please note: While I have tested this fairly extensively, I cannot guarantee that it works flawlessly on all browsers. (In particular: I have not tested cross-browser compatibility since about 2015, and a lot of things have changed since then!) Please send me feedback, either to tell me you have found this useful, or to make suggestions. Step 1: What is the total number of people in the exchange? |
|
For restrictions, a check (or X) means that combination is not allowed. check for symmetric restrictions (that is, if A cannot pick B, then B cannot pick A). check here to supply email addresses (which do not have to be unique) for some or all members of the exchange. Step 4 (notification) might be slightly easier if you enter email addresses. No email addresses are saved by this Web site, and all email messages will be sent by you, not by bluffton.edu. You can save this information (along with the current set of matches) in one of two ways:
when restrictions are complete (or to generate a new set of matches). |
While I designed this page to make it easier for my family to choose names each Christmas, I have used it as the basis for talks at Bluffton University (as part of our Mathematics Seminar), and at Miami University (at the 2015 Mathematics Conference on "Combinatorics and its Applications"). I've included links to Wikipedia to supplement the minimal technical detail given below.
You can find a fair amount of information (including most of what follows) in the PDF file from my talk at Miami.
For a group of n people, a particular set of assignments (that is, who picked who?) is equivalent to a permutation of the numbers {0, 1, 2, …, n–1}. For example, with 4 people, {2,3,1,0} (henceforth 2310, without the commas and braces) means that person 0 chose person 2, person 1 choose person 3, etc. A "basic" gift exchange (with no restrictions except that a person may not choose his/her own name) is a special kind of permutation called a derangement. Random derangements are generated using the algorithm of Martínez/Panholzer/Prodinger, published in the 2008 SIAM ANALCO Proceedings.
The number of derangements forn people (with no additional restrictions) is Dn =
. As restrictions are added, this number is obviously reduced, and can be found using rook polynomials, which you can learn more about at my page on the subject, Wikipedia, or elsewhere on the Web.
Once a particular set of assignments is chosen (e.g. 2310 or 53740126), we index the permutation by assigning a number from 0 to n!–1, so that (e.g.):