in reply to Re^10: Challenge: 8 Letters, Most Words
in thread Challenge: 8 Letters, Most Words
McA,
My brain is mush so unfortunately, this critique is just the things that jumped out at me.
My brain is mush so unfortunately, this critique is just the things that jumped out at me.
Would be better written as:%alphabet = (%alphabet, map { $_ => 1 } @chars);
I am not sure why you avoid autovivication but@alphabet{@chars} = (); # No need to set values to 1 as you only ever +use keys
Would work just as well as:if(defined $sorted{$characters}) { push @{$sorted{$characters}}, $line; } else { $sorted{$characters} = [$line]; }
You waste a lot of time going through loops that you abort earlypush @{$sorted{$characters}}, $line;
Would work a lot more efficiently as:foreach (my $pos2 = 0; $pos2 < $count; $pos2++) { next if $pos2 < $pos1;
I haven't tested it but the way you determine if one is a subset of the other would probably be better as subtracting one hash from another.for (my $pos2 = $pos1; $pos2 < $count; $pos2++) {
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^12: Challenge: 8 Letters, Most Words
by McA (Priest) on Oct 05, 2013 at 13:38 UTC | |
by Anonymous Monk on Oct 05, 2013 at 17:14 UTC | |
by davido (Cardinal) on Oct 05, 2013 at 17:45 UTC | |
by McA (Priest) on Oct 06, 2013 at 17:27 UTC |
In Section
Seekers of Perl Wisdom