diff options
| author | Scimon <simon.proctor@gmail.com> | 2025-09-15 09:39:25 +0100 |
|---|---|---|
| committer | Scimon <simon.proctor@gmail.com> | 2025-09-15 09:39:25 +0100 |
| commit | 981862b7e028e8075d93f8a977c62f849a89bb5a (patch) | |
| tree | d748676bc2fc1eaa317800b859d7a6ac3f1cbdc6 | |
| parent | 916d9d6a2edd1b5a32312ff64491a25fea979ca9 (diff) | |
| download | perlweeklychallenge-club-981862b7e028e8075d93f8a977c62f849a89bb5a.tar.gz perlweeklychallenge-club-981862b7e028e8075d93f8a977c62f849a89bb5a.tar.bz2 perlweeklychallenge-club-981862b7e028e8075d93f8a977c62f849a89bb5a.zip | |
Challenge 2
| -rwxr-xr-x | challenge-339/simon-proctor/raku/ch-2.raku | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-339/simon-proctor/raku/ch-2.raku b/challenge-339/simon-proctor/raku/ch-2.raku new file mode 100755 index 0000000000..adfeeea5ce --- /dev/null +++ b/challenge-339/simon-proctor/raku/ch-2.raku @@ -0,0 +1,21 @@ +#!/usr/bin/env raku + +subset IsTrue of Bool where so *; + +multi sub MAIN( IsTrue :t(:$test) ) is hidden-from-USAGE { + use Test; + is peak-gain(-5, 1, 5, -9, 2),1; + is peak-gain(10, 10, 10, -25),30; + is peak-gain(3, -4, 2, 5, -6, 1), 6; + is peak-gain(-1, -2, -3, -4), 0; + is peak-gain(-10, 15, 5),10; + done-testing; +} + +multi sub MAIN( *@gains where Int() ~~ all(*) ) { + peak-gain(|@gains).say; +} + +sub peak-gain( *@ints where Int() ~~ all(*) ) { + ([\+] (0, |@ints)).max; +} |
