Secret Santa Challenge


Before starting the next CodeNewbie challenge, I would like to thank everyone who has participated in the challenge thus far. You have created a wonderful variety of solutions and made this project lots of fun.

Thank you for playing. :)


Secret Santa

Secret Santa is a holiday gift-giving tradition.

The idea behind Secret Santa is to create a pool of participants that want to exchange gifts. Each participant is randomly matched with another participant in secret. No one knows which person in the pool will be getting them a gift.

The Secret Santa concludes when the gifts are exchanged and each person gives and receives a gift.


The Challenge

This challenge will ask you to generate Secret Santa partners for a list of people. The levels will begin with picking a name from the list at random and will progress to a full secret santa generator. Please choose your level based on your available time and your comfort level with the challenge.

Below is a sample list of participants:

  • Kayla Alva
  • Linh Alva
  • Mia Alva
  • Joseph Nuygen
  • Stephen Nuygen
  • Yuki Garza
  • Jill Williams
  • Cecilia Williams
  • James Williams
  • Annie Puri
  • Naveen Puri
  • Chris Puri
  • Demarco Frankel
  • Ximena Frankel
  • Xuan Thomas
  • George Thomas
  • Priya Thomas


Level 1

Choose a person from the list to represent yourself. Write a program that will select a random name from the list that is not the name that you picked.

Example / Use Case

Given the list of participants

and you are Kayla Alva

When you select a person from the list

Then that person is not Kayla Alva


Level 2

Write a program that will match each person in the secret santa list with another person in the secret santa list.  This will allow each person to give a gift and receive a gift.  However, they do not need to give a gift to the same person they received a gift from.

Example / Use Case

Given the list of participants

When you run your solution

Then each name on the list will be paired with another on the list

and a name will not be paired with itself

and each name will be paired one time


Level 3

The sample list contains multiple households that want to share gifts. Assume that each household shares a unique last name. The participants have requested that since they will be gifting within their own households that all participants are paired with a member of another household.

Example / Use Case

Given the list of participants

When you run your solution

Then each name on the list will be paired with another on the list

and a name will not be paired with itself

and each name will be paired one time

and each pair has different last names


Thank You for Your Participation

Thanks to Edwin Torres for suggesting a Secret Santa challenge. I really like this challenge because it is not only a good exercise but also timely. Perhaps someone will be able to use a solution in their own holiday gift giving.

Have an Idea for a Challenge?

If you have an idea for a challenge, we would like to know about it. Please share your idea by posting it to the discourse thread.

Sharing your Solution

If you have created a solution to a challenge and have not yet shared it to discourse, I encourage you to do so. We have seen solutions in a variety of languages and styles and posted there and would love to see yours too.