From f58c306998e73df7288f5bedbe7c84226b75631f Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Mon, 22 Sep 2025 08:52:35 +0200 Subject: Week 340, Raku solutions by @ash --- challenge-340/ash/raku/ch-1.raku | 13 +++++++++++++ challenge-340/ash/raku/ch-2.raku | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 challenge-340/ash/raku/ch-1.raku create mode 100644 challenge-340/ash/raku/ch-2.raku diff --git a/challenge-340/ash/raku/ch-1.raku b/challenge-340/ash/raku/ch-1.raku new file mode 100644 index 0000000000..1bd8d01199 --- /dev/null +++ b/challenge-340/ash/raku/ch-1.raku @@ -0,0 +1,13 @@ +# Task 1 of the Weekly Challenge 340 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-340/#TASK1 + +say redup('abbaca'); # ca +say redup('azxxzy'); # ay +say redup('aaaaaaaa'); # '' +say redup('aabccba'); # a +say redup('abcddcba'); # '' + +sub redup($str is copy) { + while $str ~~ s:g/(.) $0// {}; + return $str; +} diff --git a/challenge-340/ash/raku/ch-2.raku b/challenge-340/ash/raku/ch-2.raku new file mode 100644 index 0000000000..caa4c3a5de --- /dev/null +++ b/challenge-340/ash/raku/ch-2.raku @@ -0,0 +1,12 @@ +# Task 2 of the Weekly Challenge 340 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-340/#TASK2 + +say is-increasing('The cat has 3 kittens 7 toys 10 beds'); # True +say is-increasing('Alice bought 5 apples 2 oranges 9 bananas'); # False +say is-increasing('I ran 1 mile 2 days 3 weeks 4 months'); # True +say is-increasing('Bob has 10 cars 10 bikes'); # False +say is-increasing('Zero is 0 one is 1 two is 2'); # True + +sub is-increasing($str) { + [<] $str.comb(/\d+/) +} -- cgit