DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Ritardi Massimi
// description of your code here
require 'set'
numEstratti = 6
maxNum = 90
numIterazioni = 1000000
class Estrazione
attr_reader :valori
def initialize(k,n)
@valori = Set.new
while(@valori.size < k)
@valori.add(rand(n)+1)
end
end
def to_s
"<" + @valori.sort.join(", ") + ">"
end
end
ritardi = Array.new(maxNum,0);
maxRitardi = Array.new(maxNum,0);
for i in (1..numIterazioni)
estrazione = Estrazione.new(numEstratti, maxNum)
#puts estrazione
ritardi.map! {|k| k+=1}
estrazione.valori.each do |v|
maxRitardi[v-1] = ritardi[v-1] if maxRitardi[v-1] < ritardi[v-1]
ritardi[v-1] = 0
end
end
puts maxRitardi.max





