diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-07-16 23:04:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-16 23:04:33 +0100 |
| commit | 80ff581fd33fd291df9cdf63674f9d1cc1805659 (patch) | |
| tree | de593298ad4bfd35c84de55aac0c1f9f4651fb68 | |
| parent | 5b7d1e513c1d12ab3d040ff582b6efa280f28967 (diff) | |
| parent | d80e9ac1f7ac30de8be1ebb96306ef2db5603f95 (diff) | |
| download | perlweeklychallenge-club-80ff581fd33fd291df9cdf63674f9d1cc1805659.tar.gz perlweeklychallenge-club-80ff581fd33fd291df9cdf63674f9d1cc1805659.tar.bz2 perlweeklychallenge-club-80ff581fd33fd291df9cdf63674f9d1cc1805659.zip | |
Merge pull request #8390 from E7-87-83/newt
Week 225 Task 1
| -rw-r--r-- | challenge-225/cheok-yin-fung/perl/ch-1.pl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-225/cheok-yin-fung/perl/ch-1.pl b/challenge-225/cheok-yin-fung/perl/ch-1.pl new file mode 100644 index 0000000000..19880b7a78 --- /dev/null +++ b/challenge-225/cheok-yin-fung/perl/ch-1.pl @@ -0,0 +1,26 @@ +# The Weekly Challenge 225 +# Task 1 Max Words +use v5.30.0; +use warnings; +use List::Util qw/uniqstr/; + +sub mw { + my @list = $_[0]->@*; + my $max = 0; + s/\p{PosixPunct}/ /g for @list; + for my $sent (@list) { + my @arr; + push @arr, (split /\s+/, $sent); + my $words = uniqstr @arr; + $max = $words if $words > $max; + } + return $max; +} + +use Test::More tests=>2; +ok 8 == mw(["Perl and Raku, belong to the same family.", + "I love Perl.", + "The Perl and Raku Conference."]); +ok 7 == mw(["The Weekly Challenge.", + "Python is the most popular guest language.", + "Team PWC has over 300 members."]); |
