diff options
| -rwxr-xr-x | challenge-116/stuart-little/raku/ch-1.p6 | 10 | ||||
| -rwxr-xr-x | challenge-116/stuart-little/raku/ch-2.p6 | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/challenge-116/stuart-little/raku/ch-1.p6 b/challenge-116/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..b86a35a058 --- /dev/null +++ b/challenge-116/stuart-little/raku/ch-1.p6 @@ -0,0 +1,10 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> <number> + +sub consecSplit(Str $s) { + return (1..$s.chars).map({ $s.substr(0,$_) }).map({ (0..$s.chars).map(-> $i { $_.Int + $i }) }).map(-> @a {(0..^@a.elems).map(-> $ix {@a.[0..$ix]})}).map(-> @aa {@aa.first({ $_.join("").chars >= $s.chars })}).first({ $_.join("") eq $s }) +} + +consecSplit(@*ARGS[0]).say diff --git a/challenge-116/stuart-little/raku/ch-2.p6 b/challenge-116/stuart-little/raku/ch-2.p6 new file mode 100755 index 0000000000..de605be844 --- /dev/null +++ b/challenge-116/stuart-little/raku/ch-2.p6 @@ -0,0 +1,8 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> <number> + +my $digSqSum = @*ARGS[0].comb.map(*.Int ** 2).sum; +($digSqSum.sqrt.Int ** 2 == $digSqSum).Int.say; + |
