diff options
| author | Andrew Shitov <andy@shitov.ru> | 2020-10-12 11:51:12 +0200 |
|---|---|---|
| committer | Andrew Shitov <andy@shitov.ru> | 2020-10-12 11:51:12 +0200 |
| commit | 8bba3e7e8e995db61fee11799e7363688fe2aba0 (patch) | |
| tree | c10b32d4318db479824a8f8e72456d418dcefb8b | |
| parent | 2e7fb5ec844f60c121ef26d50e6b7f24b8849780 (diff) | |
| download | perlweeklychallenge-club-8bba3e7e8e995db61fee11799e7363688fe2aba0.tar.gz perlweeklychallenge-club-8bba3e7e8e995db61fee11799e7363688fe2aba0.tar.bz2 perlweeklychallenge-club-8bba3e7e8e995db61fee11799e7363688fe2aba0.zip | |
Raku solutions 082-1 and 082-2 by ash
| -rw-r--r-- | challenge-082/ash/raku/ch-1.raku | 16 | ||||
| -rw-r--r-- | challenge-082/ash/raku/ch-2.raku | 23 |
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-082/ash/raku/ch-1.raku b/challenge-082/ash/raku/ch-1.raku new file mode 100644 index 0000000000..f6aaef2abe --- /dev/null +++ b/challenge-082/ash/raku/ch-1.raku @@ -0,0 +1,16 @@ +#!/usr/bin/env raku +# +# Task 1 from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-082/ + +# Test runs: +# $ raku ch-1.raku 12 18 +# (1 2 3 6) +# $ raku ch-1.raku 100 500 +# (1 2 4 5 10 20 25 50 100) +# $ raku ch-1.raku 18 23 +# (1) + +my ($a, $b) = @*ARGS; + +say ((1 .. ($a max $b)).grep: $a %% *).grep: $b %% *; diff --git a/challenge-082/ash/raku/ch-2.raku b/challenge-082/ash/raku/ch-2.raku new file mode 100644 index 0000000000..0c95ea66fb --- /dev/null +++ b/challenge-082/ash/raku/ch-2.raku @@ -0,0 +1,23 @@ +#!/usr/bin/env raku +# +# Task 2 from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-082/ + +unit sub MAIN(Str $a, Str $b, Str $c); + +my @parts; +for ^$a.chars -> $pos { + say 1 and return if $c eq $a.substr(0, $pos) ~ $b ~ $a.substr($pos); +} + +# Not sure if the below tests agree with the idea of the task. + +say 2 and return if $c eq $a ~ $b; + +for ^$b.chars -> $pos { + say 3 and return if $c eq $b.substr(0, $pos) ~ $a ~ $b.substr($pos); +} + +say 4 and return if $c eq $b ~ $a; + +say 0; |
