C:\Users\tblaz\Documents\evelyn>perl 1.board.pl [ [ { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, ... { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, ], ] input is acehioo Found 7,012 1-7 letter strings in acehioo. Found 33 words in acehioo. chiao : 5 achoo : 5 ciao : 4 chao : 4 echo : 4 ohia : 4 chia : 4 coho : 4 each : 4 ache : 4 ich : 3 oca : 3 chi : 3 ice : 3 hic : 3 hae : 3 ace : 3 hao : 3 hie : 3 ooh : 3 oho : 3 hoe : 3 coo : 3 ho : 2 oh : 2 ha : 2 ai : 2 hi : 2 ah : 2 eh : 2 ae : 2 he : 2 oe : 2 { ace => 3, ache => 4, achoo => 5, ae => 2, ah => 2, ai => 2, chao => 4, chi => 3, chia => 4, chiao => 5, ciao => 4, coho => 4, coo => 3, each => 4, echo => 4, eh => 2, ha => 2, hae => 3, hao => 3, he => 2, hi => 2, hic => 3, hie => 3, ho => 2, hoe => 3, ice => 3, ich => 3, oca => 3, oe => 2, oh => 2, ohia => 4, oho => 3, ooh => 3, } C:\Users\tblaz\Documents\evelyn>perl 1.board.pl [ [ { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, ...=> "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, { height => 0, letter => "." }, ], ] input is aachhil Found 3,591 1-7 letter strings in aachhil. Found 26 words in aachhil. chalah : 6 laich : 5 chia : 4 hila : 4 hail : 4 haha : 4 laic : 4 lich : 4 aha : 3 hah : 3 ich : 3 aal : 3 hic : 3 chi : 3 ail : 3 aah : 3 lac : 3 ala : 3 ai : 2 ah : 2 la : 2 ha : 2 aa : 2 al : 2 li : 2 hi : 2 { aa => 2, aah => 3, aal => 3, ah => 2, aha => 3, ai => 2, ail => 3, al => 2, ala => 3, chalah => 6, chi => 3, chia => 4, ha => 2, hah => 3, haha => 4, hail => 4, hi => 2, hic => 3, hila => 4, ich => 3, la => 2, lac => 3, laic => 4, laich => 5, li => 2, lich => 4, } C:\Users\tblaz\Documents\evelyn><\c>

Source:

#!/usr/bin/perl use 5.011; use warnings; use Path::Tiny; use Algorithm::Permute; use Number::Format 'format_number'; use List::Util 'uniq', 'shuffle'; use Data::Dump; # the board my @board; foreach my $row ( 0 .. 9 ) { foreach my $col ( 0 .. 9 ) { $board[$row][$col] = { letter => '.', height => 0 }; } } my $refBoard = \@board; dd $refBoard; ## quick and dirty... my @letters = split //, 'aaaaaaaaabbccddddeeeeeeeeeeeeffgggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz'; my @my_orig_chars = ( shuffle @letters )[ 0 .. 6 ]; my $input = join '', map "$_", sort @my_orig_chars; say "input is $input"; my $length = length $input; my @input_chars = split '', $input; my $words_file = 'c:\users\tblaz\documents\html_template_data\dict\enable1.txt'; my %words = map { $_ => 1 } path($words_file)->lines( { chomp => 1 } ); my @partials; for ( 1 .. $length ) { my $P = Algorithm::Permute->new( \@input_chars, $_ ); while ( my @res = $P->next ) { push @partials, join '', @res; } } @partials = uniq @partials; #say "partials are @partials"; say sprintf 'Found %s 1-%s letter strings in %s.', format_number( scalar @partials ), $length, $input; my %found = map { $_ => calc_score($_) } grep { $words{$_} } @partials; my $ref_found = \%found; say sprintf 'Found %s words in %s.', format_number( scalar keys %found ), $input; #my $debug =0; for ( sort { $found{$b} <=> $found{$a} } keys %found ) { say "$_ : $found{$_}"; } dd $ref_found; ############### sub calc_score { my $word = shift; my $val; $val = length $word; return $val; } __END__