diff options
| author | CY Fung <fungcheokyin@gmail.com> | 2023-04-23 21:26:12 +0800 |
|---|---|---|
| committer | CY Fung <fungcheokyin@gmail.com> | 2023-04-23 21:26:12 +0800 |
| commit | 8905596cdc73283f589ef2d5c777d85246b90472 (patch) | |
| tree | fef78c8c11e6635cef5a89a1bbb108c2f9d2262a | |
| parent | 85f44e291bf5c2f1676e5e0e041a60e1aa963411 (diff) | |
| download | perlweeklychallenge-club-8905596cdc73283f589ef2d5c777d85246b90472.tar.gz perlweeklychallenge-club-8905596cdc73283f589ef2d5c777d85246b90472.tar.bz2 perlweeklychallenge-club-8905596cdc73283f589ef2d5c777d85246b90472.zip | |
Week 213 Task 1
| -rw-r--r-- | challenge-213/cheok-yin-fung/perl/ch-1.pl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-213/cheok-yin-fung/perl/ch-1.pl b/challenge-213/cheok-yin-fung/perl/ch-1.pl new file mode 100644 index 0000000000..5ceb058327 --- /dev/null +++ b/challenge-213/cheok-yin-fung/perl/ch-1.pl @@ -0,0 +1,17 @@ +# The Weekly Challenge 213 +# Task 1 Fun Sort +use v5.30.0; +use warnings; + +sub fs { + my @list = @_; + my @elist = grep {!($_ % 2)} @list; + my @olist = grep {$_ % 2} @list; + return ((sort {$a<=>$b} @elist) , (sort {$a<=>$b} @olist)); +} + +use Test::More tests=>3; +use Test::Deep; +cmp_deeply [fs(1,2,3,4,5,6)], [2,4,6,1,3,5]; +cmp_deeply [fs(1,2)], [2,1]; +cmp_deeply [fs(1)], [1]; |
