Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (13)
    As of 2018-01-23 14:17 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (247 votes). Check out past polls.