[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fwd: Please Forward: Ruby Quiz Submission

James Gray

6/6/2007 10:07:00 PM

Begin forwarded message:

> From: "Linklater, Lloyd \(IT\)" <LINKLLL@voughtaircraft.com>
> Date: June 6, 2007 1:05:08 PM CDT
> To: <submission@rubyquiz.com>
> Subject: Please Forward: Ruby Quiz Submission
>
> ok. oops! The reverses are very important. Here is a fix. I was
> giving the worst pick not the best. heh
>
> ar = Array.new
> stats = Array.new
> bestStats = Array.new
> 10_000.times do |k|
> 6.times do |j|
> 4.times {|i| ar[i] = rand(6)}
> ar.sort!
> stats[j] = ar[1] + ar[2] + ar[3] + 3
> end
> bestStats[k] = stats.sort.reverse
> end
> bestStats.sort!.reverse!
> p bestStats[0]
>