Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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 +"; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://689889]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-01-23 14:55 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (192 votes). Check out past polls.