diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-04-26 11:36:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-26 11:36:37 +0100 |
| commit | c142b9a61b586c4a93a27ddab59f7d68b426eb4a (patch) | |
| tree | db5f1d53e2891d3c1231a08b761ac65555b6665b | |
| parent | 996c2a2b9ac7d6c27d2cc318b2d5819ab8e855a3 (diff) | |
| parent | f5ce484e98886fd715a86d086368c26e969ec487 (diff) | |
| download | perlweeklychallenge-club-c142b9a61b586c4a93a27ddab59f7d68b426eb4a.tar.gz perlweeklychallenge-club-c142b9a61b586c4a93a27ddab59f7d68b426eb4a.tar.bz2 perlweeklychallenge-club-c142b9a61b586c4a93a27ddab59f7d68b426eb4a.zip | |
Merge pull request #1627 from Doomtrain14/master
Update for non unique whole word
| -rw-r--r-- | challenge-057/yet-ebreo/perl/ch-2.pl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/challenge-057/yet-ebreo/perl/ch-2.pl b/challenge-057/yet-ebreo/perl/ch-2.pl index 85092a443b..1500740ab4 100644 --- a/challenge-057/yet-ebreo/perl/ch-2.pl +++ b/challenge-057/yet-ebreo/perl/ch-2.pl @@ -11,11 +11,15 @@ sub uniq_prefix { splice @copy, $_, 1; my $prefix; + my $flag = 0; for my $size (1..length $word) { $prefix = substr $word, 0, $size; - last unless grep { /^$prefix/ } @copy + unless (grep { /^$prefix/ } @copy ) { + $flag = 1; + last; + } } - $prefix; + $flag?$prefix:'na'; } 0..$#{$words}; } |
