- or download this
# Scrabble distribution
our %letter_distribution = qw(
...
u 4 v 2 w 2 x 1
y 2 z 1
) ;
- or download this
sort { score_word($a) cmp score_word($b) }
- or download this
sort { score_word($a) <=> score_word($b) }
- or download this
# search for matching words
my @possible_words =
...
sort { $a->[ 0 ] <=> $b->[ 0 ] }
map length() == length( $word_pattern ) && pattern_word( $word_pat
+tern, $_ ) ? [ score_word( $_ ), $_ ] : (),
@dictionary;
- or download this
sub score_word {
my ($word) = @_ ;
...
$points += $letter_points{$_} foreach @letters ;
return $points ;
}
- or download this
use List::Util qw/ sum /;
sub score_word { sum( @letter_points{ split //, $_[ 0 ] } ) }
- or download this
my %deny_letters = map { $_ => 1 } split(//, $pattern) ;
my @p = split //, $pattern ;
- or download this
my @p = split //, $pattern ;
my %deny_letters = map { $_ => 1 } @p ;