diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2023-07-11 09:33:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-11 09:33:57 +0100 |
| commit | 266de55cce0e50e1d68c951250a6e15d75f96cc4 (patch) | |
| tree | b38c031a56e31f7e52748d19a68b3f3f4234609c | |
| parent | 0110f0dab8191790ed4e919d3f49f40a2f069f22 (diff) | |
| parent | ef95427490fc6f52da98cb1dbabc31e844619523 (diff) | |
| download | perlweeklychallenge-club-266de55cce0e50e1d68c951250a6e15d75f96cc4.tar.gz perlweeklychallenge-club-266de55cce0e50e1d68c951250a6e15d75f96cc4.tar.bz2 perlweeklychallenge-club-266de55cce0e50e1d68c951250a6e15d75f96cc4.zip | |
Merge pull request #8349 from andemark/challenge-225-Raku
Challenge 225 Solutions (Raku)
| -rw-r--r-- | challenge-225/mark-anderson/raku/ch-1.raku | 15 | ||||
| -rw-r--r-- | challenge-225/mark-anderson/raku/ch-2.raku | 18 |
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-225/mark-anderson/raku/ch-1.raku b/challenge-225/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..847f907e52 --- /dev/null +++ b/challenge-225/mark-anderson/raku/ch-1.raku @@ -0,0 +1,15 @@ +#!/usr/bin/env raku +use Test; + +is max-words(("Perl and Raku belong to the same family.", + "I love Perl.", + "The Perl and Raku Conference.")), 8; + +is max-words(("The Weekly Challenge.", + "Python is the most popular guest language.", + "Team PWC has over 300 members.")), 7; + +sub max-words($list) +{ + $list>>.words>>.elems.max +} diff --git a/challenge-225/mark-anderson/raku/ch-2.raku b/challenge-225/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..d2a831657f --- /dev/null +++ b/challenge-225/mark-anderson/raku/ch-2.raku @@ -0,0 +1,18 @@ +#!/usr/bin/env raku +use Test; + +is-deeply left-right-sum-diff((10,4,8,3)), (15,1,11,22); +is-deeply left-right-sum-diff((1)), (0,); +is-deeply left-right-sum-diff((1,2,3,4,5)), (14,11,6,1,10); + +sub infix:<|-|>($a, $b) { abs $a - $b } + +sub left-right-sum-diff($n) +{ + my $list = (0, |$n, 0); + + my $left = [\+] $list[^(*-2)]; + my $right = ([\+] $list[$list.end...2]).reverse; + + $left >>|-|<< $right +} |
