aboutsummaryrefslogtreecommitdiff
path: root/challenge-063
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-06-03 00:10:47 +0200
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-06-03 00:10:47 +0200
commit63c5c89eea1bf157760f2af02a3faac27fc97424 (patch)
tree26fe30f8fbdd3eb826d5d8eb1e903065c98dbbea /challenge-063
parent8a2fd344ddf0dddac5348be199b53a091cecff12 (diff)
downloadperlweeklychallenge-club-63c5c89eea1bf157760f2af02a3faac27fc97424.tar.gz
perlweeklychallenge-club-63c5c89eea1bf157760f2af02a3faac27fc97424.tar.bz2
perlweeklychallenge-club-63c5c89eea1bf157760f2af02a3faac27fc97424.zip
initial
Diffstat (limited to 'challenge-063')
-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..d4eedaf53e
--- /dev/null
+++ b/challenge-063/markus-holzer/ch-1.raku
@@ -0,0 +1,8 @@
+sub last-word($string, $regexp)
+{
+ $string.words.grep( $regexp ).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..2bc8aff3fe
--- /dev/null
+++ b/challenge-063/markus-holzer/ch-2.raku
@@ -0,0 +1,19 @@
+say r('xyxx');
+
+multi sub r( Str $orig )
+{
+ r $orig.comb.List
+}
+
+multi sub r( List $orig )
+{
+ my $work = $orig;
+
+ for ( 1 .. Inf ).map( * % 4 ).kv -> $n, $by
+ {
+ $work = $work.rotate: $by;
+
+ return $n + 1
+ if $work cmp $orig == Same;
+ }
+} \ No newline at end of file