aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-02-09 23:17:25 +0000
committerGitHub <noreply@github.com>2021-02-09 23:17:25 +0000
commit9e362b06c799483b5982600ff71ea6bef8ca28ca (patch)
tree25f28f6374c30fb5e96a7255192619c3450bf16c
parent23627294f74b0bbf76894bb7f3810902c84b8b3d (diff)
parent6dfe12bed3720406ca147a0c719299739c41a0cf (diff)
downloadperlweeklychallenge-club-9e362b06c799483b5982600ff71ea6bef8ca28ca.tar.gz
perlweeklychallenge-club-9e362b06c799483b5982600ff71ea6bef8ca28ca.tar.bz2
perlweeklychallenge-club-9e362b06c799483b5982600ff71ea6bef8ca28ca.zip
Merge pull request #3483 from fluca1978/pwc99
Pwc99
-rw-r--r--challenge-099/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-099/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-099/luca-ferrari/raku/ch-1.p610
-rw-r--r--challenge-099/luca-ferrari/raku/ch-2.p615
4 files changed, 27 insertions, 0 deletions
diff --git a/challenge-099/luca-ferrari/blog-1.txt b/challenge-099/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..57e7046809
--- /dev/null
+++ b/challenge-099/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/02/08/PerlWeeklyChallenge99.html#task1
diff --git a/challenge-099/luca-ferrari/blog-2.txt b/challenge-099/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..8247db63d4
--- /dev/null
+++ b/challenge-099/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/02/08/PerlWeeklyChallenge99.html#task2
diff --git a/challenge-099/luca-ferrari/raku/ch-1.p6 b/challenge-099/luca-ferrari/raku/ch-1.p6
new file mode 100644
index 0000000000..570a3b0c66
--- /dev/null
+++ b/challenge-099/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,10 @@
+#!raku
+
+sub MAIN( Str $S, Str $P ) {
+ # substitute every ? to match a single char
+ # and every * to match a stream of chars
+ # and add anchors
+ my $regexp = '^' ~ $P.subst( '*', '.*' ).subst( '?', '.' ) ~ '$';
+ { say 1; exit; } if $S ~~ / <$regexp> /;
+ say 0;
+}
diff --git a/challenge-099/luca-ferrari/raku/ch-2.p6 b/challenge-099/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..a25a297500
--- /dev/null
+++ b/challenge-099/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,15 @@
+#!raku
+
+sub MAIN( Str $S, Str $T ) {
+ my $counter = 0;
+ my $regexp = $T.comb.join( '.*' );
+
+ # overlapping search
+ given $S {
+ for m:exhaustive/ <$regexp> / -> $match {
+ $counter++;
+ }
+ }
+
+ say $counter;
+}