diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-09-01 20:12:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-01 20:12:50 +0100 |
| commit | 07c546039cc44586d864d87252fbbaf7f6fd48bf (patch) | |
| tree | 8d89b62c287b4b88f113da9922160572efd7f169 | |
| parent | 87b63d3827da9980b2a3fb29f28b477a62b67cbd (diff) | |
| parent | fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae (diff) | |
| download | perlweeklychallenge-club-07c546039cc44586d864d87252fbbaf7f6fd48bf.tar.gz perlweeklychallenge-club-07c546039cc44586d864d87252fbbaf7f6fd48bf.tar.bz2 perlweeklychallenge-club-07c546039cc44586d864d87252fbbaf7f6fd48bf.zip | |
Merge pull request #12610 from Scimon/master
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; +} |
