I used a genetic algorithm that tries to find the best solution
possible in a given number of iterations.  It doesn't always find the
best, but generally does pretty well.  And because there are
randomized aspects to each run, you can end up with different
solutions (of different scores) on consecutive runs.  The code can be
found at:

    http://learnruby.com/examples/ruby-quiz-165.shtml

Eric

====

LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE
workshops.
   Ruby Fundamentals Wkshp          June 16-18     Ann Arbor, Mich.
   Ready for Rails Ruby Wkshp       June 23-24     Ann Arbor, Mich.
   Ruby on Rails Wkshp              June 25-27     Ann Arbor, Mich.
   Ruby Plus Rails Combo Wkshp      June 23-27     Ann Arbor, Mich
Please visit http://LearnRuby.com for all the details.