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

Re^2: One for the weekend: challenge

by Anonymous Monk
on Jun 03, 2008 at 14:09 UTC ( #689889=note: print w/ replies, xml ) Need Help??


in reply to Re: One for the weekend: challenge
in thread One for the weekend: challenge

Slightly faster :)

#!perl use strict; my %dict; @ARGV = qw( d.dict d.input ); while(<>) # read in both files, load dict on first, match on second { chomp; (my $d = lc) =~ tr|a-z"/-|57630499617851881234762239|d; @ARGV ? push @{$dict{$d}}, $_ : match($d, 0, "$_:"); } sub match # (to match, last was digit, matches) { my ($in, $digit, @have, $k) = @_; map match(substr($in, $k), !++$digit, @have, $_), @{$dict{substr $in, 0, $k = $_}} for 2..length $in; $in =~ s/(.)// ? $digit || match($in, 1, @have, $1) : print "@have\n +"; }


Comment on Re^2: One for the weekend: challenge
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://689889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2014-07-24 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (165 votes), past polls