Skip to content

Produces and emails secret santas. Also estimates probabilities of each secret-santa pairing.

License

Notifications You must be signed in to change notification settings

jtwalsh0/secret-santa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Secret Santa Program

Secret Santa

is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they anonymously give a gift. Often practiced in workplaces or amongst large families, participation in it is usually voluntary. It offers a way for many people to give and receive a gift at low cost, since the alternative gift tradition is for each person to buy gifts for every other person. In this way, the Secret Santa tradition also encourages gift exchange groups whose members are not close enough to participate in the alternative tradition of giving presents to everyone else.

This software helps administer a Secret Santa exchange by performing three basic tasks:

  1. ASSIGN SECRET SANTAS: The program randomly pairs gifters with giftees and checks whether the user prohibited any of them (for example, the user might prohibit a husband getting his wife). If any assignment is prohibited, the program repeats until all the assignments are acceptable.
  2. EMAIL EACH PARTICIPANT HER ASSIGNMENT: This program uses R's mail package, which sends a maximum of 20 emails a day. See the mail documentation about disabling that limit.
  3. ESTIMATE THE PROBABILITY OF EACH SECRET SANTA PAIRING: The program uses simulation to estimate the probability of each pairing. This not only informs the user about participant X's chances of drawing participant Y; it also provides a check that the program correctly understood the user's pairing prohibitions (for example, spouses cannot draw each other.)

Participant Data

This program loads participant data (names; email addresses; and lists of prohibited assignees, such as spouses) from a user-created comma-separated file in the working directory with the name "secret santa participants.csv". The file should have the following structure:

  • Participant names in the first column
  • Participant email addresses in the second column
  • The names of people the participant cannot get separated by a comma in the third column
  • Variable names are "names", "email.addresses", and "prohibited".

Here is an example:

names email.addresses prohibited
Mike R. [email protected]
Mike W. [email protected] Amy,John
Amy [email protected] Mike W.
John [email protected] Mike W.
Emily [email protected]

Be sure to use unique names.

Using R

I wrote the code in R, a free and widely-used statistics-oriented programming language. There are several excellent references for R beginners:

This software relies on R's mail package. For more information on how to install this and other R packages, see here.

About

Produces and emails secret santas. Also estimates probabilities of each secret-santa pairing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages