The three rules of Ruby Q.:

Please do not post any solutions or spoiler discussion for this quiz
until
48 hours have passed from the time on this message. 
Support Ruby Q. by submitting ideas as often as you can:
 Enjoy!
========================================
by Bob S.
I was a Cub Scout leader for five years and one of our favorite
activities was
the annual Pinewood Derby. For you nonScouts, this is a competition
between
small gravitypowered cars made by the boys using standard kits
containing a
wood block, plastic wheels, and nails for axles. The cars compete
against each
other down a sloping, multilane track (26 lanes is typical) about 30
feet
long.
Some Cub Scout packs use a “ladder” elimination system for their derby,
but this
isn’t much fun for the boys that are eliminated early. Much more
enjoyable is a
“roundrobin” approach that lets each boy’s car run in the same number
of heats,
racing against different opponents each time.
You can find links to more Pinewood Derby information at:
http://members.aol.com/StanDCmr/pwportal.html
This week’s task is to create a Ruby program to generate a chart for a
Pinewood
derby. In order to make the event fair, each car should be scheduled
into each
lane of the track the same number of times (to compensate for any lane
differences due to track imperfections.) We’ll use the term “round” to
refer to
each car running once in each lane. The input to your program will be:
Number of cars
Number of lanes
Number of rounds
For example, let’s assume we have 25 cars and a 4lane track. If we want
each
car to run twice in each lane (2 “rounds”), that means:
Number of rounds: 2
Number of runs per car: 2 rounds x 4 lanes = 8
Total number of runs: 8 runs/car x 25 cars = 200
Total number of heats: 200 / 4 lanes = 50 heats
So we have to come up with a chart that assigns the cars to lanes and
heats. If
we number the lanes from 1 to 4 and the cars from 125, our chart might
look
something like this:
Heat Lane 1 Lane 2 Lane 3 Lane 4
    
1: 9 2 13 10
2: 12 8 5 21
3: 16 19 6 4
...and so on
The trick is to create a chart that is as fair as possible. A “perfect”
chart
would be one in which:
1) Each car runs in the same number of heats
2) Each car runs in each lane an equal number of times
3) Each car runs against every other opponent an equal number of times
4) The heats a car is assigned to are evenly spread throughout the
event. (In
other words, a boy shouldn’t run in the first 8 heats and then have
to sit
out for the rest of the event.)
In practice, you cannot create a perfect chart for all combinations of
inputs.
For instance, if we ran just one round with our 25 cars, each car would
run in 4
heats and face 12 opponents (3 opponents per heat). Since there are 24
opponents, it isn’t possible to face all the opponents equally. But you
would
want to try to maximize the number of opponents faced, rather than
having two
cars face each other several times.
You may want to create a function to evaluate your chart against the
criteria
above, so you can rank charts as to their “quality”.