You can just randomize the order of the list (with n people) and have person[x] give to person[x+1] until person[n], who gives to person[0]. classic linked list, jah?
On Tue, 27 Nov 2001, Jeremy Zawodny wrote: > Since it's the holiday season, someone recently asked me if I could > hack out a quick script to setup a "scecret santa" system. The basic > idea was this: > > Feed a script a bunch of e-mail addresses. The script will assign > each person (address) the address of someone they should give a > gift to. Each person only gives one gift and receives one gift. > Of course, nobody will give a gift to themselves. (It should also > e-mail everyone automatically so that the person running the > script doesn't even know the outcome--but I didn't worry about > that part at all.) > > What I managed to hack out was rather ugly. I'm unhappy with it. > It just didn't feel like the *right* solution, since it had some odd > logic in it. That fact that I was watching TV at the time probably > didn't help. > > Anyone done this before and come up with something they think is > particularly elegant or clever? > > Jeremy > -- > Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo! > <[EMAIL PROTECTED]> | http://jeremy.zawodny.com/ >
