From: James Edward Gray II Date: 2007-03-12T05:43:18+09:00 Subject: Re: [QUIZ] SimFrost (#117) On Mar 11, 2007, at 3:07 PM, Christoffer Lern� wrote: > It's interesting that it looks like everyone populated their grid > using a randomizer for each position in the grid. > > This is is obviously fast, but for small grids (and low > percentages), the percentage of actual generated vapour particles > may be off by quite a bit. What's a "small grid" and what's "quite a bit"? ;) #!/usr/bin/env ruby -w TRIALS = 10_000 SIZE = 80*22 sum = 0 high = low = nil TRIALS.times do grid = Array.new(SIZE) { rand < 0.3 ? "." : " " } percent = (grid.grep(/\./).size / SIZE.to_f * 100).round puts "Actual percentage: #{percent}" if $DEBUG sum += percent low = percent if low.nil? or percent < low high = percent if high.nil? or percent > high end puts <> Average: 29 # >> High: 35 # >> Low: 26 James Edward Gray II