Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2015-04-27 08:02 GMT
Find Nodes?
    Voting Booth?

    Who makes your decisions?

    Results (497 votes), past polls