From: Gavin Kistner Date: 2004-10-04T21:59:00+09:00 Subject: Re: [SOLUTION] Secret Santas (#2) On Oct 4, 2004, at 2:43 AM, Peter wrote: > The way you look at it, each person in your arrangement is the next > person's secret Santa, wrapping around the end of the array as needed, > right? Actually that's like putting people in a circle such that each > person's secret Santa is standing to his/her left (or right). Correct. (Indeed, I wrote my own circular list class because that's exactly how I was looking at it :) > But actually that leaves out the arrangements with multiple smaller > circles, so you > can't generate every solution this way. Good point...I hadn't considered that! Is it a good or bad thing that these smaller circles might be two reciprocating people? I suppose it adds to the surprise if/when it occurs. > But James' solution does however. Apparently my RRC (Ruby Reading Comprehension) is not good. I misunderstood Jame's solution at first. I didn't realize it was a 1<->1 mapping in to lists. (I failed to see that there were both $players and $santas being compared in his #check_families? method.) I like the smaller-circles possibility, and if speed were a problem, you could add people to $santas in a more deterministic fashion (randomize a copy, and then find the first available slot for the person) rather easily. The multiplicity of solutions here is pretty sweet. :) -- (-, /\ \/ / /\/