[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:06:00 PM

Begin forwarded message:

> From: "Linklater, Lloyd \(IT\)" <LINKLLL@voughtaircraft.com>
> Date: June 6, 2007 1:11:09 PM CDT
> To: <submission@rubyquiz.com>
> Subject: Please Forward: Ruby Quiz Submission
>
> Ok, I know that this has got to be annoying, but it is my first
> time and I just had to ask. Is this a better way to do it?
>
> ar = Array.new
> stats = Array.new
> bestStats = Array.new
> 10_000.times do |k|
> 6.times do |j|
> ar = [rand(6), rand(6), rand(6), rand(6)].sort
> stats[j] = ar[1] + ar[2] + ar[3] + 3
> end
> bestStats[k] = stats.sort.reverse
> end
> p bestStats.sort.reverse[0]
>
> OK. Even if I think of a super improvement, I will keep it to
> myself. Thanks again!
>
> Lloyd Linklater
>