diff options
| author | Andrew Shitov <mail@andreyshitov.com> | 2025-05-06 09:05:11 +0200 |
|---|---|---|
| committer | Andrew Shitov <mail@andreyshitov.com> | 2025-05-06 09:05:11 +0200 |
| commit | 8ea8086138c6dd8e3d691070a56a9a664cddcf27 (patch) | |
| tree | d949574f8632ac5f3381039d7421bd4e0c8bdf3e | |
| parent | 4865a9cce3c19c5a1def20017a083f17ef9a0809 (diff) | |
| download | perlweeklychallenge-club-8ea8086138c6dd8e3d691070a56a9a664cddcf27.tar.gz perlweeklychallenge-club-8ea8086138c6dd8e3d691070a56a9a664cddcf27.tar.bz2 perlweeklychallenge-club-8ea8086138c6dd8e3d691070a56a9a664cddcf27.zip | |
Challenge 320, solutions by ash
| -rw-r--r-- | challenge-320/ash/raku/ch-1.raku | 11 | ||||
| -rw-r--r-- | challenge-320/ash/raku/ch-1a.raku | 8 | ||||
| -rw-r--r-- | challenge-320/ash/raku/ch-2.raku | 8 |
3 files changed, 27 insertions, 0 deletions
diff --git a/challenge-320/ash/raku/ch-1.raku b/challenge-320/ash/raku/ch-1.raku new file mode 100644 index 0000000000..077cd1fad6 --- /dev/null +++ b/challenge-320/ash/raku/ch-1.raku @@ -0,0 +1,11 @@ +# Task 1 of the Weekly Challenge 320 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-320/#TASK1 + +my @ints = -3, -2, -1, 1, 2, 3; # 3 +# my @ints = -2, -1, 0, 0, 1; # 2 +# my @ints = 1, 2, 3, 4; # 4 + +my @pos = @ints.grep: * > 0; +my @neg = @ints.grep: * < 0; + +say max(@pos.elems, @neg.elems); diff --git a/challenge-320/ash/raku/ch-1a.raku b/challenge-320/ash/raku/ch-1a.raku new file mode 100644 index 0000000000..e4917dbbbd --- /dev/null +++ b/challenge-320/ash/raku/ch-1a.raku @@ -0,0 +1,8 @@ +# Task 1 of the Weekly Challenge 320 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-320/#TASK1 + +my @ints = -3, -2, -1, 1, 2, 3; # 3 +# my @ints = -2, -1, 0, 0, 1; # 2 +# my @ints = 1, 2, 3, 4; # 4 + +say @ints.grep(* != 0).classify(* < 0)>>.elems.values.max; diff --git a/challenge-320/ash/raku/ch-2.raku b/challenge-320/ash/raku/ch-2.raku new file mode 100644 index 0000000000..26359ed294 --- /dev/null +++ b/challenge-320/ash/raku/ch-2.raku @@ -0,0 +1,8 @@ +# Task 2 of the Weekly Challenge 320 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-320/#TASK2 + +my @ints = 1, 23, 4, 5; # 18 +# my @ints = 1, 2, 3, 4, 5; # 0 +# my @ints = 1, 2, 34; # 27 + +say abs(@ints.sum - @ints.comb.sum);
\ No newline at end of file |
