Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swalkinshaw
Last active December 14, 2023 20:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swalkinshaw/7a97b5e76549713ee00c7be89be78731 to your computer and use it in GitHub Desktop.
Save swalkinshaw/7a97b5e76549713ee00c7be89be78731 to your computer and use it in GitHub Desktop.
Secret Santa

Holiday Gift Exchange Problem

Description

A Holiday gift exchange is where a group of people are randomly assigned one other person in the group to buy a gift for. This person can be anyone else in the group except for themselves. Everyone should both give and receive a gift.

Design a program that reads a provided CSV file, performs the matching, and then prints out the matches. Assume that you may email the match to the person later, but focus on printing first.

The format of the CSV is name,email on each row.

Don't actually send email for this example. Assume the system or framework has a mail delivery system available.

Chris chris@example.com
Felix felix@example.net
Elizabeth lizzy1994@example.com
André andre@example.fr
Milo milo.milo@example.com
Olivia olive99@example.net
Hugo hugo124@example.net
Amit amit.123@example.com
Ludwig ludwig@example.net
Raoul raoul@example.com
Kirk j.t.kirk@starfleet.example.com
Spock s.t.spock@starfleet.example.com
McCoy l.mccoy@starfleet.example.com
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 2 columns, instead of 3. in line 1.
AAA,a@example.com
BBB,b@example.com,AAA
CCC,c@example.com,
DDD,d@example.com,AAA,BBB,CCC
EEE,e@example.com,AAA,DDD
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 2 columns, instead of 3. in line 1.
Ali,ali@example.com
Pat,pat@example.com,Ali
Chris,chris@example.com,Shawn,Ali,Pat
Shawn,shawn@eample.com,Chris,Ali
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 2 columns, instead of 3. in line 1.
Ali,ali@example.com
Pat,pat@example.com,Ali
Chris,chris@example.com,Pat,Shawn,Tyler
Shawn,shawn@example.com,Chris,Ali
Tyler,tyler@example.com,Chris,Pat,Shawn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment