M


Mystery Problem

See Games for an explaination and possible free beer. Code by LloydCarr.


while("" ne ($char = getc)) {
   if($char =~ /[A-Za-z]/) {
      $word = $word.$char;
   } elsif( $word ne "") {

      $try = $word;
      $try =~  tr/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;
      if($try !~ /q|z/) {
         $try =~  tr/abcdefghijklmnoprstuvwxy/222333444555666777888999/;
         if($try !~ /2[2789]|3[34789]|4[4369]|55|6[647]|7[72369]|8[823]|9[92347]/) {
            $score = 0;
            $length = length $try;
            for ($i = 0; $i < $length; $i++)  {
               $score += substr( $try, $i, 1);
            }
            if($score > 55 ) {print  "$word\t$try\t$score\n";}
         }
      }

      $word = "";
   }
}