aboutsummaryrefslogtreecommitdiff
path: root/challenge-063
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-06-06 19:51:51 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-06-06 19:51:51 +0100
commitcc978c3bfaf276c210d79a5cfe8f1a65f980df2c (patch)
tree70ed16aa1107848fbaceac89fd2e82b9b4c0e6f4 /challenge-063
parent54d20f20ef823f09837b871b033abf99face137d (diff)
downloadperlweeklychallenge-club-cc978c3bfaf276c210d79a5cfe8f1a65f980df2c.tar.gz
perlweeklychallenge-club-cc978c3bfaf276c210d79a5cfe8f1a65f980df2c.tar.bz2
perlweeklychallenge-club-cc978c3bfaf276c210d79a5cfe8f1a65f980df2c.zip
- Added solutions by Shahed Nooshmand.
Diffstat (limited to 'challenge-063')
-rw-r--r--challenge-063/shahed-nooshmand/blog.txt1
-rw-r--r--challenge-063/shahed-nooshmand/raku/ch-1.p611
-rw-r--r--challenge-063/shahed-nooshmand/raku/ch-2.p613
3 files changed, 25 insertions, 0 deletions
diff --git a/challenge-063/shahed-nooshmand/blog.txt b/challenge-063/shahed-nooshmand/blog.txt
new file mode 100644
index 0000000000..154e1ee384
--- /dev/null
+++ b/challenge-063/shahed-nooshmand/blog.txt
@@ -0,0 +1 @@
+https://rafraichisso.ir/2020/06/06/pwc-63
diff --git a/challenge-063/shahed-nooshmand/raku/ch-1.p6 b/challenge-063/shahed-nooshmand/raku/ch-1.p6
new file mode 100644
index 0000000000..b39fdc2917
--- /dev/null
+++ b/challenge-063/shahed-nooshmand/raku/ch-1.p6
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl6
+
+use v6.d;
+
+sub MAIN(Str $string, Regex $regex) {
+ last-word($string, $regex);
+}
+
+sub last-word(Str $string, Regex $regex) {
+ .return when $regex for $string.words.reverse
+}
diff --git a/challenge-063/shahed-nooshmand/raku/ch-2.p6 b/challenge-063/shahed-nooshmand/raku/ch-2.p6
new file mode 100644
index 0000000000..93038e9545
--- /dev/null
+++ b/challenge-063/shahed-nooshmand/raku/ch-2.p6
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+
+say find-r “xyxyxy”;
+
+sub find-r($string) {
+ my $p = find-p $string;
+ .return when $_ × ($_ + 1) ÷ 2 %% $p for 1..∞
+}
+
+sub find-p($string) {
+ my $n = chars $string;
+ .return when $string.substr(^$_) x $n ÷ $_ eq $string for |(1..$n ÷ 2).grep($n %% *), $n
+}