Skip to content

Instantly share code, notes, and snippets.

@ndisampson
Last active July 8, 2021 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndisampson/7da0cdd43cef05c494e3b5b2ee6adb63 to your computer and use it in GitHub Desktop.
Save ndisampson/7da0cdd43cef05c494e3b5b2ee6adb63 to your computer and use it in GitHub Desktop.
Conde Nast - Secret Santa Problem

Problem 1: Implement a Secret Santa Matching Algorithm



The algorithm should take a set of names and return a set of pairs of names chosen randomly as follows:



  • Each person’s name is put in “a hat”.

  • Each person randomly draws a name from a hat, and becomes that person’s Secret Santa (they’ll buy an anonymous gift for that person)

  • If a person draws their own name, they draw again.


Example:

INPUT:

['adam', 'betty', 'charlie', 'dante']

OUTPUT:

[
  ['adam', 'dante'],
  ['betty', 'charlie'],
  ['charlie', 'adam'],
  ['dante', 'betty']
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment