diff options
| author | Mark Anderson <mark@frontrangerunner.com> | 2020-06-05 20:55:53 -0600 |
|---|---|---|
| committer | Mark Anderson <mark@frontrangerunner.com> | 2020-06-05 20:55:53 -0600 |
| commit | 780cd706fbfb79f67846c55e4b2bb3b213bf58e6 (patch) | |
| tree | cb06459d46a91f80a954743cf5ab16576290b640 | |
| parent | ec6c79405511d4ee3f3cd61820c6b8d98b0e9fbc (diff) | |
| download | perlweeklychallenge-club-780cd706fbfb79f67846c55e4b2bb3b213bf58e6.tar.gz perlweeklychallenge-club-780cd706fbfb79f67846c55e4b2bb3b213bf58e6.tar.bz2 perlweeklychallenge-club-780cd706fbfb79f67846c55e4b2bb3b213bf58e6.zip | |
Challenge 63 Solutions
| -rw-r--r-- | challenge-063/mark-anderson/raku/ch-1.raku | 12 | ||||
| -rw-r--r-- | challenge-063/mark-anderson/raku/ch-2.raku | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-063/mark-anderson/raku/ch-1.raku b/challenge-063/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..5affbfd16d --- /dev/null +++ b/challenge-063/mark-anderson/raku/ch-1.raku @@ -0,0 +1,12 @@ +#!/usr/bin/env raku + +say last_word(' hello world', rx/<[ea]>l/); +say last_word("Don't match too much, Chet!", rx:i/ch.t/); +say last_word("spaces in regexp won't match", rx:s/in re/); +say last_word(join(' ', 1..1e6), rx/^(3.*?)**3/); + +sub last_word(Str $string, Regex $regexp) { + + return $string.split(/\s+/).grep($regexp).Array.pop || Nil; + +} diff --git a/challenge-063/mark-anderson/raku/ch-2.raku b/challenge-063/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..f8d58772c3 --- /dev/null +++ b/challenge-063/mark-anderson/raku/ch-2.raku @@ -0,0 +1,11 @@ +#!/usr/bin/env raku + +sub MAIN(Str $str = "xyxx") { + my @arr = $str.comb; + + for 1 .. Inf -> $i { + next if $i %% $str.chars; + @arr .= rotate($i % $str.chars); + say $i and last if @arr.join eq $str; + } +} |
