aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-06-03 00:33:54 +0100
committerGitHub <noreply@github.com>2020-06-03 00:33:54 +0100
commit2fdaaa88959c34a46a9db6e8a2a9864ba4716673 (patch)
treec5fa036d18aa71c076d005949f0c7a878f030b7a
parent8a2fd344ddf0dddac5348be199b53a091cecff12 (diff)
parented2d152a6409d6400a82092ba820c6397b9be11b (diff)
downloadperlweeklychallenge-club-2fdaaa88959c34a46a9db6e8a2a9864ba4716673.tar.gz
perlweeklychallenge-club-2fdaaa88959c34a46a9db6e8a2a9864ba4716673.tar.bz2
perlweeklychallenge-club-2fdaaa88959c34a46a9db6e8a2a9864ba4716673.zip
Merge pull request #1787 from holli-holzer/master
initial
-rw-r--r--challenge-063/markus-holzer/ch-1.raku8
-rw-r--r--challenge-063/markus-holzer/ch-2.raku19
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-063/markus-holzer/ch-1.raku b/challenge-063/markus-holzer/ch-1.raku
new file mode 100644
index 0000000000..7336e63f9c
--- /dev/null
+++ b/challenge-063/markus-holzer/ch-1.raku
@@ -0,0 +1,8 @@
+sub last-word( Str $sentence, Regex $matcher )
+{
+ $sentence.words.grep( $matcher ).tail;
+}
+
+say last-word( ' hello world', rx/ <[ea]> l / ); # 'hello'
+say last-word( "Don't match too much, Chet!", rx:i/ ch . t / ); # 'Chet!'
+say last-word( "spaces in regexp won't match", rx/ \s re / ); # undef
diff --git a/challenge-063/markus-holzer/ch-2.raku b/challenge-063/markus-holzer/ch-2.raku
new file mode 100644
index 0000000000..ba1eb40be2
--- /dev/null
+++ b/challenge-063/markus-holzer/ch-2.raku
@@ -0,0 +1,19 @@
+multi sub rotmodN( Str $orig )
+{
+ rotmodN $orig.comb.List
+}
+
+multi sub rotmodN ( List $orig, $n = $orig.elems )
+{
+ my $work = $orig;
+
+ for ( 1 .. Inf ).map( * % $n ).kv -> $i, $by
+ {
+ $work = $work.rotate: $by;
+
+ return $i + 1
+ if $work cmp $orig == Same
+ }
+}
+
+say rotmodN 'xyxx' \ No newline at end of file