From fd4e54a20099ae15e1b269c12bb93ec9efa6e5ae Mon Sep 17 00:00:00 2001 From: Scimon Date: Mon, 1 Sep 2025 15:29:57 +0100 Subject: Challenge 1 --- challenge-337/simon-proctor/raku/ch-1.raku | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 challenge-337/simon-proctor/raku/ch-1.raku 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; +} -- cgit