Skip to content

Instantly share code, notes, and snippets.

@cea2k
Created August 12, 2011 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cea2k/1142262 to your computer and use it in GitHub Desktop.
Save cea2k/1142262 to your computer and use it in GitHub Desktop.
Script para Evaluar loto
#!/usr/bin/ruby
$resultados = {
:comodin => 16,
:sorteos => {
:loto => [6,18,21,22,29,34].sort,
:revancha => [2,4,10,18,19,41].sort,
:desquite => [1,7,10,12,27,28].sort,
}
}
pool_juegos = [
#18:57:34
[8,20,27,36,37,38],
[14,20,21,30,33,39],
[3,13,28,29,40,41],
[20,22,27,31,38,39],
[5,10,25,37,40,41],
[3,8,11,30,38,39],
[6,12,23,25,34,36],
[16,17,22,23,26,36],
[12,18,21,34,39,40],
[04,24,34,36,39,40],
#18:58:10
[6,10,20,33,35,39],
[5,9,12,26,33,41],
[3,7,12,23,29,36],
[2,3,11,19,22,25],
[2,12,19,20,26,40],
[1,5,7,19,20,33],
[15,22,23,29,34,36],
[1,7,11,16,31,39],
[19,20,21,33,36,41],
[5,7,13,17,27,38],
#18:59:08
[3,13,23,29,34,35],
[15,20,24,32,33,35],
[10,11,17,18,35,37],
[2,11,20,22,36,41],
[6,14,18,29,40,41],
[9,27,30,37,40,41],
[20,24,29,31,32,35],
[7,12,22,23,28,30],
[11,16,20,32,36,40],
[13,23,24,25,36,38],
#18:59:41
[2,7,25,27,33,38],
[2,12,22,26,28,34],
[7,10,14,26,29,31],
[6,12,20,22,24,41],
[2,6,16,18,20,38],
[3,6,8,12,22,37],
[15,21,23,30,35,40],
[2,24,28,31,33,38],
[9,13,17,18,22,33],
[4,9,16,22,34,36],
#19:00:12
[16,20,29,30,32,40],
[16,18,23,25,35,40],
[6,7,18,22,31,40],
[2,11,20,23,25,34],
[3,5,13,24,29,30],
[11,14,21,29,31,34],
[1,4,11,22,34,36],
[3,8,14,17,26,29],
[21,23,28,35,37,39],
[14,18,25,26,31,37],
#19:00:43
[20,21,27,34,39,40],
[2,6,17,23,37,40],
[4,16,18,29,36,38],
[2,4,12,17,40,41],
[9,13,16,18,23,38],
[3,9,19,25,27,31],
[1,7,12,15,19,28],
[4,5,28,31,36,39],
[7,12,23,32,35,37],
[7,9,15,16,31,34],
#19:00:59
[15,20,25,28,33,34],
[6,8,17,27,28,36],
[13,23,26,32,37,41]
]
def compute_matches(sorteo, juego)
matches = 0
sorteo.each {|n| matches += 1 if juego.include?(n)}
matches
end
$nombre_premios = [
"",
"",
"Dupla",
"Terna",
"Cuaterna",
"Quina",
"LOTO!!"
]
$evaluators = {
:loto => Proc.new do |tupla|
matches = compute_matches($resultados[:sorteos][:loto], tupla)
comodin = tupla.include?($resultados[:comodin])
if matches > 1
(comodin ? "SUPER " : "") + $nombre_premios[matches] + " (" + (comodin ? "#{matches} + 1" : matches.to_s) + ")"
else
""
end
end,
:revancha => Proc.new do |tupla|
(tupla == $resultados[:sorteos][:revancha]) ? "REVANCHA" : ""
end,
:desquite => Proc.new do |tupla|
(tupla == $resultados[:sorteos][:desquite]) ? "DESQUITE" : ""
end
}
def evaluar(tupla)
outcome = ""
$resultados[:sorteos].each_key do |sorteo|
if outcome.empty?
outcome = $evaluators[sorteo].call(tupla)
end
end
outcome
end
puts "Probando con los propios sorteos"
$resultados[:sorteos].each_key do |sorteo|
tupla = $resultados[:sorteos][sorteo].sort
puts sorteo.to_s.ljust(10) + ": [" + tupla.map{ |i| i.to_s.rjust(2, "0") }.join(',') + "] : " + evaluar(tupla)
end
puts
puts "Ahora evaluando juegos"
pool_juegos.each do |tupla|
tupla = tupla.sort
puts "juego: [" + tupla.map{ |i| i.to_s.rjust(2, "0") }.join(',') + "] : " + evaluar(tupla)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment