|
"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
|