Skip to content

Instantly share code, notes, and snippets.

@breim
Created November 21, 2014 02:22
Show Gist options
  • Save breim/cb655a5024c377b45768 to your computer and use it in GitHub Desktop.
Save breim/cb655a5024c377b45768 to your computer and use it in GitHub Desktop.
Megasena
count = Array.new(60) {| i | i +1} # Array de objetos
resultado_mega = [1,21,22,27,32,45]
i = 0
data_de_inicio = Time.now
valor_do_jogo = 2
array_gerado = []
while array_gerado != resultado_mega do
array_gerado = count.sample(6).sort!
i+=1
if array_gerado == resultado_mega
puts "ACHOOOU"
puts "Tentativa numero #{i} - #{array_gerado} - R$ #{valor_do_jogo * i}"
data_de_fim = Time.now
tempo = data_de_inicio - data_de_fim
puts tempo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment