Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Comment on

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

Exhaustive search should work for any dictionary. (The 10 secs doesn't include the sort, but it could use a high watermark.):

#! perl -slw use strict; use Time::HiRes qw[ time ]; sub uniq{ my %x; @x{@_} = (); keys %x } my $start = time; my @lookup = map{ my $bits = pack 'C', $_; [ grep vec( $bits, $_, 1 ), 0 .. 7 ] } 0 .. 255; my %dict; while( <> ) { chomp; next if length > 8; my $r = \%dict; $r = $r->{ $_ } //= {} for sort split '', $_; push @{ $r->{_} }, $_; } my %stats; sub X { my( $first, $soFar, $tree ) = @_; if( @$soFar == 8 ) { my @words = uniq map { my $r = \%dict; $r = $r->{ $_ } for @{ $soFar }[ @{ $lookup[ $_ ] } ]; exists $r->{_} ? @{ $r->{_} } : (); } 0 .. 255; $stats{ join '', @$soFar } = \@words; return; } for( $first .. 'z' ) { next unless exists $tree->{ $_ }; X( $_, [ @$soFar, $_ ], $tree->{ $_ } ); } return; } X( 'a', [], \%dict ); print time - $start; <STDIN>; printf "[%d] %s : @{[ @{$stats{ $_ }} ]}\n", scalar @{$stats{$_}}, $_ +for sort{ @{ $stats{ $b } } <=> @{ $stats{ $a } } } keys %stats; __END__ [ 7:09:30.87] C:\test>1056884-calc 2of12inf.txt 10.4807748794556 [346] aeinprst : nape tars pets ape panties taper inept nastier print +airs spinet sniper pane rants pint peat spear terns tears trains reps earn tines paints napes ate strep rest repaint ti inapt ri +nse ripest astir priest neat part nets pans retina apes tarps reaps nip rain tern res sip sprint instep sear inters in prints +ires erst parent snip re astern satire praise stein pirates pirate pertains tan tar pie par tis nite ant apter pa ants rites ranis + rite eta as pastier rents nit ties pastern rate sapient strip pants pits apt pent snipe niters ran pate tsar stain pints panie +r spirea rapines tapers repast irate pars span pairs tens raps ripen stair tarn tans retsina tin rips pies inert eats reins ear +esprit aster rapes pin tarsi sera neaps rani step rein resin inter piastre stria painters sprain neap tripes tires raise tier en st +ern parents pas ares sari pert satin sine nitres ripens tape prates striae retain arts pet ani sat tare pertain insert reap pit pra +te pea trap antsier pantie sterna tries rasp east pen spit sit arise naps tire tea pares pat snare stir spar pine rap tares is pa +n rant earns pant art it painter sate pear tips pens rep pitas tarp penis aspen antis teas nips tap aspire piaster traps past pier er +a ears asp sane star seat entrap rip snit siren sin nae pins spare tapes stare niter spate sitar rent prise taps anti trip trips ti +ns spire ens tarns spent traipse antes tripe rise tapir tip pest peas nest sent its sir pries retains anise rat pates pare rats tr +ain saner pita eat nitre spat parse tapirs tiers ten risen nears sap spite set stripe sprite paniers sire strap tie sea septa pis + site psi eras repaints an pain paste ripe ire net entraps nits pair apse pains rates rapt per saint near paint rains spin strain + etas snap pines rapist rape are rapine sepia pantries spine peats tear at parties pi ante sprat retinas inset spa arisen ins parts + nites tine piers panes pats nap pears air [344] aeilprst : liars tars platies pets ape taper lairs airs lire lit +er ails peat spear plies palest tears lets lest reps ate strep rest lips leis slate ti ripest astir lie priest seal part apes t +arps piles reaps trial plate res sip paler litres sear retail ires erst rails salt plates re satire praise pirates pirate lea + liras tar pie retails pleas par pleats tis apter pa realist pelt rites peril alters rite relit stale eta earls as litre pa +stier lies trails ties rate strip pits apt petal pate list tsar spirea tapers petals repast irate pars plea pairs pleat stap +ler raps stair saltier lit pales tali alert rips spilt pies eats laser ear peal slit esprit aster rapes tarsi sera ales slip +alit spelt step alter piastre silt stria tripes tires raise liar tier leapt tiler teals pas ares sari sale pert tape prates +pal striae riles sail alp plats arts pet plait sat tare reap pit late pails steal prate least pea tiles trap tries slier rasp +sepal pastel east spit sit arise alps tire tea pares pat rial stir spar laps later rap tares is la rials ilea leas staler alert +s art it last sate ale aisle pear tips leaps rep pitas tarp trail lept tile stile teas tap aspire piaster teal traps past tai +l pier split era ears asp star seat pile rip spare rile tapes stare spate sitar pelts triples las prise islet lisper lepta tap +s plaster staple trip pail spiel lair pilaster trips slat pearl spire lip traipse tripe rise tapir lei pale tip slept pest peas +tilers its sir lite pries rat pearls serial rail pates pare rats lapse tails pita eat slap spat pals parse plaits tapirs lisp + tiers lap pliers salter tales sap spite set real ail stripe sprite sire strap splat tie sea septa pis site psi eras plat pa +ste ripe ire let pair apse leap rates rapt per triple etas perils rapist rape liters lira are trials spiral sepia peats tear + at parties pi earl peals sprat spa isle parts tale piers pats pears air ...

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Challenge: 8 Letters, Most Words (2of12int.txt in 20^H^H 10 secs; Pure Perl) by BrowserUk
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
    NodeReaper wonders through a maze of twisty little sayings, all alike

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (2)
    As of 2018-04-22 09:10 GMT
    Find Nodes?
      Voting Booth?