MData


DanielAllen's solution to the Mystery Problem. It was more fun with a Hash of Hashes, but then I realized, even that was overkill.

#!/usr/bin/perl -w
# 
# usage: cat /usr/dict/words | m.pl 
# by da on 17 Sept. 2004

my $n=2;
my $regex;

while (<DATA>) {
    # generate disallowed pairs
    $regex .= "$n$_|" foreach (split);
    $n++;
}
chop $regex;

while (<>) {
    chomp;
    next if ( /[qz\W]/i );
    my $score = 0;
    my $try = lc($_);
    $try =~ tr/[a-z]/2223334445556667 77888999 /;
    $try =~ s/\s//;
    next if $try =~ /$regex/;
    $score += $_ foreach (split //, $try);
    
    print "$score\t$_\t$try\n" if ($score > 55);
}

# one line per keypad digit
__DATA__
2 7 8 9
3 4 7 8 9
4 3 6 9
5
6 4 7
7 2 3 6 9
8 2 3
9 2 3 4 7