aboutsummaryrefslogtreecommitdiff
path: root/challenge-161
diff options
context:
space:
mode:
authorE7-87-83 <fungcheokyin@gmail.com>2022-04-19 18:03:11 +0800
committerE7-87-83 <fungcheokyin@gmail.com>2022-04-19 18:03:11 +0800
commit247a814ff8f4cc4b468a39eba534522aaede7001 (patch)
treeb0564dcffbe0995a143db0aa2ddfdf5c0c720068 /challenge-161
parent12bff60d124929a294cdb09332e2818a3b502419 (diff)
downloadperlweeklychallenge-club-247a814ff8f4cc4b468a39eba534522aaede7001.tar.gz
perlweeklychallenge-club-247a814ff8f4cc4b468a39eba534522aaede7001.tar.bz2
perlweeklychallenge-club-247a814ff8f4cc4b468a39eba534522aaede7001.zip
More flexible ch-2.pl
Diffstat (limited to 'challenge-161')
-rw-r--r--challenge-161/cheok-yin-fung/perl/ch-2.pl8
1 files changed, 5 insertions, 3 deletions
diff --git a/challenge-161/cheok-yin-fung/perl/ch-2.pl b/challenge-161/cheok-yin-fung/perl/ch-2.pl
index 157845912a..23fd2d143c 100644
--- a/challenge-161/cheok-yin-fung/perl/ch-2.pl
+++ b/challenge-161/cheok-yin-fung/perl/ch-2.pl
@@ -27,8 +27,10 @@ foreach (<DICT>) {
}
-my @three_letter_words = grep {length $_ == 3} @words;
-my @four_letter_words = grep {length $_ == 4} @words;
+# if the dictionary is very large,
+# using only 3- and 4-letter words might improve the execution time
+# my @three_letter_words = grep {length $_ == 3} @words;
+# my @four_letter_words = grep {length $_ == 4} @words;
@@ -62,7 +64,7 @@ sub update_found {
sub next_pan {
my $new_word;
my $fine = 0;
- for my $w (shuffle (@three_letter_words, @four_letter_words)) {
+ for my $w (shuffle (@words)) {
if ((scalar grep { !$found_alphabet{$_} } split "", $w) == 1) {
$new_word = $w;
$fine = 1;