On 6/19/2006 11:54 PM, Jeremy Kister wrote:
I wrote a word descrambler that works very well, but is very slow compared to http://www.jumble.org
already found a very important piece that I missed ($lfound).. while(1){ print "word: "; chop(my $scramble = <STDIN>); $scramble =~ s/\s+//g; my $slen = length($scramble); my @s = split //, $scramble; foreach my $word (@{$dictionary{$slen}}){ my @w = split //, $word; my $found; foreach my $sl (0..($slen-1)){ my $lfound; foreach my $l (0..($slen-1)){ if($s[$sl] eq $w[$l]){ delete $w[$l]; $found++; $lfound=1; last; } } last unless($found && $lfound); } next unless($found == $slen); print "$word\n"; } } -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>