Thread Subject: Secret Santa

Subject: Secret Santa

From: Daniel

Date: 16 Nov, 2009 10:26:02

Message: 1 of 2

I am looking for a Matlab program that will draw the names for a secret santa. The rules of secret santa are pretty straight forward: each member of the group is "santa" (i.e., buys a gift) for another member of the group. Each member of the group must have one and only one santa. Further, you cannot be your own santa. I have a list of email addresses and the corresponding names and would like Matlab to email each person who they are santa for. It seems like there may be an elegant solution to this, I just do not see it yet..

Subject: Secret Santa

From: Jos

Date: 16 Nov, 2009 12:41:01

Message: 2 of 2

"Daniel " <daniel_shub@yahoo.com> wrote in message <hdr9bq$2im$1@fred.mathworks.com>...
> I am looking for a Matlab program that will draw the names for a secret santa. The rules of secret santa are pretty straight forward: each member of the group is "santa" (i.e., buys a gift) for another member of the group. Each member of the group must have one and only one santa. Further, you cannot be your own santa. I have a list of email addresses and the corresponding names and would like Matlab to email each person who they are santa for. It seems like there may be an elegant solution to this, I just do not see it yet..

This "shuffling" of set members is known as a derangement, a special kind of permutation.

See my RANDPERMFULL for an implementation in ML:
http://www.mathworks.com/matlabcentral/fileexchange/23257-randpermfull

Group = {'A','B','C','D'} ;
Ridx = randpermfull(numel(Group))
Santa = Group(Ridx)

hth
Jos

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
derangement Jos (10584) 16 Nov, 2009 07:44:08
rssFeed for this Thread

Contact us at files@mathworks.com