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

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 surveying the Monastery: (4)
As of 2017-07-29 11:58 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (435 votes). Check out past polls.