Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

OK, this uses some fairly naive heuristics to narrow down the search field. I'm sure somebody can do better, though I'd be fairly surprised if anybody came up with an answer that differed from mine by more than 2 letters.

use v5.14; use Sort::Key::Top 'nkeytopsort'; sub sort_letters { my @letters = split '', $_[0]; join '', sort @letters; } sub can_make { my ($letters, $word) = @_; $word = join '.*', sort split '', $word; $letters =~ qr{$word}; } say "Reading words from dictionary..."; open my $dict, '<', '/usr/share/dict/words'; chomp( my @WORDS = map lc, grep length($_) <= 9, <$dict> ); say "Scoring microcombinations..."; my %SCORE; $SCORE{ sort_letters($_) }++ for @WORDS; my @GOOD = nkeytopsort { $SCORE{$_} } -40 => keys %SCORE; say "Generating candidate answers..."; my %CANDIDATES; for my $x (@GOOD) { for my $y (@GOOD) { for my $z (@GOOD) { my $letters = sort_letters substr("$x$y$z", 0, 8); $CANDIDATES{$letters}++; } } } my @VERYGOOD = nkeytopsort { $SCORE{$_} } -40 => keys %CANDIDATES; say "Finding best candidate answer..."; my %RESULTS = map { my $letters = $_; my @can_make = grep can_make($letters, $_), @WORDS; say " $letters - ", scalar(@can_make); $letters => \@can_make; } @VERYGOOD; my ($BEST) = nkeytopsort { scalar @{$RESULTS{$_}} } -1 => @VERYGOOD; say "BEST: $BEST"; say for sort @{$RESULTS{$BEST}};

The dictionary used was the standard /usr/share/dict/words supplied with Ubuntu 13.04.

The best set of letters it found was "aeinprst" which could make 426 words. (The list appears to have some duplicates because some words appear in /usr/share/dict/words more than once with different cases.)

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

In reply to Re: Challenge: 8 Letters, Most Words by tobyink
in thread Challenge: 8 Letters, Most Words by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (12)
    As of 2014-07-22 13:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (113 votes), past polls