aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-10-01 23:23:57 +0100
committerGitHub <noreply@github.com>2025-10-01 23:23:57 +0100
commit5c05acd07b55d4ff40b4518468bd0535b32cd464 (patch)
tree6ba8b10aa17c1243ad9a31b31ef957558700b94f
parentc04ba8fd1d4060c8bc5e8a44fd1707c8bda205d9 (diff)
parent9a07e50d0b214d9ecd1701a86387b39c4bf41a0a (diff)
downloadperlweeklychallenge-club-5c05acd07b55d4ff40b4518468bd0535b32cd464.tar.gz
perlweeklychallenge-club-5c05acd07b55d4ff40b4518468bd0535b32cd464.tar.bz2
perlweeklychallenge-club-5c05acd07b55d4ff40b4518468bd0535b32cd464.zip
Merge pull request #12773 from torgnylyon/master
Add solutions for week 341
-rw-r--r--challenge-341/torgny-lyon/blog.txt1
-rwxr-xr-xchallenge-341/torgny-lyon/perl/ch-1.pl18
-rwxr-xr-xchallenge-341/torgny-lyon/perl/ch-2.pl16
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-341/torgny-lyon/blog.txt b/challenge-341/torgny-lyon/blog.txt
new file mode 100644
index 0000000000..e28f2f7938
--- /dev/null
+++ b/challenge-341/torgny-lyon/blog.txt
@@ -0,0 +1 @@
+https://www.abc.se/~torgny/pwc.html#341
diff --git a/challenge-341/torgny-lyon/perl/ch-1.pl b/challenge-341/torgny-lyon/perl/ch-1.pl
new file mode 100755
index 0000000000..28f1c99e17
--- /dev/null
+++ b/challenge-341/torgny-lyon/perl/ch-1.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+
+use v5.36;
+
+use Test::More tests => 5;
+
+sub count_words {
+ grep {
+ my $word = $_;
+ ! grep { index($word, $_) >= 0 } @{ $_[1] };
+ } split / /, lc $_[0];
+}
+
+is(count_words('Hello World', ['d']), 1);
+is(count_words('apple banana cherry', [ 'a', 'e' ]), 0);
+is(count_words('Coding is fun', []), 3);
+is(count_words('The Weekly Challenge', [ 'a', 'b' ]), 2);
+is(count_words('Perl and Python', ['p']), 1);
diff --git a/challenge-341/torgny-lyon/perl/ch-2.pl b/challenge-341/torgny-lyon/perl/ch-2.pl
new file mode 100755
index 0000000000..5712143816
--- /dev/null
+++ b/challenge-341/torgny-lyon/perl/ch-2.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use v5.36;
+
+use Test::More tests => 5;
+
+sub reverse_prefix {
+ my $i = index($_[0], $_[1]) + 1;
+ reverse(substr $_[0], 0, $i) . substr $_[0], $i;
+}
+
+is(reverse_prefix("programming", "g"), "gorpramming");
+is(reverse_prefix("hello", "h"), "hello");
+is(reverse_prefix("abcdefghij", "h"), "hgfedcbaij");
+is(reverse_prefix("reverse", "s"), "srevere");
+is(reverse_prefix("perl", "r"), "repl");