Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
A brute force approach, using the 2of12inf.txt dictionary.

use Modern::Perl; open my $DICT, '<', './2of12inf.txt' or die "Could not open dictionary +: $!"; my @dictionary; my %words8; my %results; while (<$DICT>) { chomp; next unless $_; chop if /%$/; next if length > 8; my $sorted = join '', sort split ''; push @dictionary, $sorted; $words8{$sorted}++ if length == 8; } my $maxword = 0; my $solution = ''; for my $word8 ( keys %words8 ) { my $regex = join '?', split '', $word8; for my $word (@dictionary) { $results{$word8}++ if $word =~ /($regex?)/ and $1 eq $word; } if ( $results{$word8} > $maxword ) { $maxword = $results{$word8}; $solution = $word8; say "$solution can make $maxword words"; } } say "Finished";
Output:
aabdellu can make 55 words abellrsu can make 118 words aeikprrs can make 131 words ahopstuw can make 136 words ... acehprst can make 288 words adeinrst can make 313 words adeoprst can make 316 words aeilprst can make 344 words aeinprst can make 346 words Finished
Corrected the "off-by-one" error.

Re-corrected the off-by-one error which was due to an empty line in the small test dictionaries I used.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

In reply to Re: Challenge: 8 Letters, Most Words by CountZero
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 imbibing at the Monastery: (6)
    As of 2014-09-16 04:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (156 votes), past polls