From: James Edward Gray II Date: 2004-10-04T00:54:46+09:00 Subject: Re: [SOLUTION] Secret Santas (#2) I had to rewrite my solution, because the true program takes more things into account than I mentioned in the quiz, but this is pretty much a direct simplification. I used a random sort, which of course, isn't at all elegant. James Edward Gray II #!/usr/bin/env ruby require "net/smtp" unless ARGV.size == 1 puts "Usage: #{$0} SMTP_SERVER\n" exit end $players = STDIN.readlines.map { |line| line.chomp } $santas = $players.sort_by { rand } def check_families? $players.each_with_index do |who, i| return false if who[/\S+ To: #{santa} Subject: Secret Santa Pick #{santa[/\S+/]}: You have been chosen as the Secret Santa for #{$players[i]}. Merry Christmas. Secret Santa Selection Script (by James) END_OF_MESSAGE begin server.send_message( message, "james@grayproductions.net", santa[(santa.index("<") + 1)...santa.index(">")] ) rescue puts "A message could not be sent to #{santa}.\n#{$!}" end end end __END__