diff options
| author | Scimon <simon.proctor@gmail.com> | 2025-09-01 15:29:57 +0100 |
|---|---|---|
| committer | Scimon <simon.proctor@gmail.com> | 2025-09-01 15:29:57 +0100 |
| commit | fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae (patch) | |
| tree | acf5c928e85b5737ecd7dbb5f1e0011c8c93275a | |
| parent | e80c93c27044ee16a834a9ee64a0087c1c7d0b1d (diff) | |
| download | perlweeklychallenge-club-fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae.tar.gz perlweeklychallenge-club-fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae.tar.bz2 perlweeklychallenge-club-fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae.zip | |
Challenge 1
| -rwxr-xr-x | challenge-337/simon-proctor/raku/ch-1.raku | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-337/simon-proctor/raku/ch-1.raku b/challenge-337/simon-proctor/raku/ch-1.raku new file mode 100755 index 0000000000..e216fd655f --- /dev/null +++ b/challenge-337/simon-proctor/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +multi sub MAIN(:t(:$test)) is hidden-from-USAGE { + use Test; + is smaller-than(6, 5, 4, 8), (2, 1, 0, 3); + is smaller-than(7, 7, 7, 7), (3, 3, 3, 3); + is smaller-than(5, 4, 3, 2, 1), (4, 3, 2, 1, 0); + is smaller-than(-1, 0, 3, -2, 1), (1, 2, 4, 0, 3); + is smaller-than(0, 1, 1, 2, 0), (1, 3, 3, 4, 1); + done-testing; +} + +sub smaller-than( *@vals ) { + return @vals.map( -> $v { state $i //=-1; $i++; @vals[0..^$i,$i^..*].flat.grep(* <= $v).elems; } ); +} + +multi sub MAIN(*@args where all(@args) ~~ Int()) { + smaller-than(|@args).join(",").say; +} |
