Google Chromebook puzzle arithmétique 3

Bon après 1h30 de recherche à deux, on a trouvé une bonne partie, il manque un petit quelque chose (qu'on réussi à deviner avec un peu de bon sens), ce qui nous manque doit être résolu avec l'espèce de compteur. Mais en attendant voici le script qui résoud l'énigme numéro 3 des Google chromebook puzzle. Voir ici : https://www.google.fr/chromebook/puzzles/puzzle3.html !

EDIT : Merci à carreau, donc le cadran ne servait à rien. Et il fallait bosser sur des floats ! J'ai donc rajouter des ".0" et j'ai testé == 24.0

signe = {
"b" => [ "*", "+", "-" ],
"c" => [ "*", "*", "*" ],
"d" => [ "*", "*", "+" ],
"e" => [ "*", "*", "-" ],
"f" => [ "+", "+", "+" ],
"g" => [ "+", "+", "-" ],
"h" => [ "*", "/", "/" ],
"i" => [ "*", "*", "/" ],
"j" => [ "/", "/", "+" ],
"k" => [ "-", "-", "-" ],
"l" => [ "/", "-", "-" ],
"m" => [ "/", "+", "-" ],
"n" => [ "*", "/", "-" ],
"o" => [ "*", "/", "+" ],
"p" => [ "/", "/", "-" ],
"q" => [ "/", "/", "/" ],
"r" => [ "+", "-", "-" ],
"s" => [ "*", "+", "+" ],
"t" => [ "*", "-", "-" ],
"u" => [ "/", "+", "+" ]
}
chiffre = [
{:a => [6,6,6,9]},
{:a => [5,5,9,9]},
{:a => [4,5,10,11]},
{:a => [10,12,12,12]},
{:a => [1,1,13,13]},
{:a => [2,8,9,12]},
{:a => [4,4,7,13]},
{:a => [2,5,7,9]},
{:a => [3,5,12,12]},
{:a => [3,8,8,12]},
{:a => [8,8,12,13]},
{:a => [4,7,8,10]},
{:a => [4,5,10,12]},
{:a => [4,4,5,5]},
{:a => [1,1,2,11]},
{:a => [3,3,3,5]},
{:a => [2,3,5,6]},
{:a => [2,3,12,12]},
{:a => [11,12,13,13]},
{:a => [3,4,5,10]},
{:a => [5,9,10,11]},
{:a => [3,3,5,10]},
{:a => [2,5,8,8]},
{:a => [2,2,2,3]},
{:a => [2,5,6,9]},
{:a => [3,9,9,11]},
{:a => [2,2,5,7]},
{:a => [3,3,3,11]},
{:a => [2,5,7,7]}
]
str = ""
# Sur le array de chiffre
for ary in chiffre
  # combi
  r = []
  ary[:a].permutation(4) do |c|
    # boucle signe
    signe.each_pair do |k, v|
      v.permutation(3) do |sign|
        tempcalcul = c[0].to_s + ".0" + sign[0] + c[1].to_s + ".0" + sign[1] + c[2].to_s + ".0" + sign[2] + c[3].to_s + ".0"
        if eval(tempcalcul) == 24.0
          r << k
        end
      end
    end
  end
  pp r.group_by{|l| l}.map { |k,v| {k => v.length} }
end

Executez le script : ruby script.rb et lisez les lettres dans l'ordre : Internet en moins de huit secondes .