aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2023-04-23 23:24:35 +0100
committerGitHub <noreply@github.com>2023-04-23 23:24:35 +0100
commit0d32ddc16932a6e9c3011bef128e5a735ce3b34e (patch)
tree0b0ef614c111f43186acdfedd74319ffc529ba69
parent2288bd049f6999a145fe3b3b09bac09e6079dccb (diff)
parent0378c53ec4a403bf8e73bfe894e5547a86fc30a1 (diff)
downloadperlweeklychallenge-club-0d32ddc16932a6e9c3011bef128e5a735ce3b34e.tar.gz
perlweeklychallenge-club-0d32ddc16932a6e9c3011bef128e5a735ce3b34e.tar.bz2
perlweeklychallenge-club-0d32ddc16932a6e9c3011bef128e5a735ce3b34e.zip
Merge pull request #7958 from 0rir/213
213
-rw-r--r--challenge-213/0rir/raku/ch-1.raku43
1 files changed, 43 insertions, 0 deletions
diff --git a/challenge-213/0rir/raku/ch-1.raku b/challenge-213/0rir/raku/ch-1.raku
new file mode 100644
index 0000000000..57f4091f40
--- /dev/null
+++ b/challenge-213/0rir/raku/ch-1.raku
@@ -0,0 +1,43 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # 🦋 ∅∪∩∋∈∉ ≡ ≢ «␤ » ∴
+use v6.d;
+use Test;
+
+=begin comment
+213-1: Fun Sort Submitted by: Mohammad S Anwar
+Given a list of positive integers, sort the all even integers first then
+all odds in ascending order.
+
+Example 1
+Input: @list = (1,2,3,4,5,6)
+Output: (2,4,6,1,3,5)
+Example 2
+Input: @list = (1,2)
+Output: (2,1)
+Example 3
+Input: @list = (1)
+Output: (1)
+=end comment
+
+my @Test =
+ # @in @exp
+ [], [],
+ [1,2,3,4,5,6], [2,4,6,1,3,5],
+ [1,2], [2,1],
+ [1], [1],
+ [100,100,99,9,10,2,3], [2,10,100,100,3,9,99],
+ [1,2,3,-9,10], [2,10,-9,1,3],
+ [ -100,100,-99,-9,-10,2,3], [ -100,-10,2,100,-99,-9,3],
+ [2,5,4,3,1,1,3,10,22,44,66,88,110,5,9,7],
+ [2,4,10,22,44,66,88,110,1,1,3,3,5,5,7,9],
+;
+plan @Test ÷ 2;
+
+for @Test -> @in, @exp {
+ is @in.sort( { $_ % 2, $_}), @exp, "@in[] --> @exp[]";
+}
+my @list = 100,100,99,9,10,2,3;
+say "\nInput: @list = (@list.join(','))
+Output: (@list.sort( { $_ % 2, $_}).join(','))";
+exit;
+