aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-02-10 20:18:23 +0000
committerGitHub <noreply@github.com>2025-02-10 20:18:23 +0000
commitddeb3e1f986f901280cff456bda31803fc803a99 (patch)
tree7d1fd65f3df2b866cb20145cc6ead0cd57b8b9bf
parentae17a86ae304313f8a7423e429375ace6dab4d83 (diff)
parentcf09e8b28196791107caad4bd70eb159cfc7a545 (diff)
downloadperlweeklychallenge-club-ddeb3e1f986f901280cff456bda31803fc803a99.tar.gz
perlweeklychallenge-club-ddeb3e1f986f901280cff456bda31803fc803a99.tar.bz2
perlweeklychallenge-club-ddeb3e1f986f901280cff456bda31803fc803a99.zip
Merge pull request #11560 from wlmb/challenges
Solve PWC308
-rw-r--r--challenge-308/wlmb/blog.txt1
-rwxr-xr-xchallenge-308/wlmb/perl/ch-1.pl16
-rwxr-xr-xchallenge-308/wlmb/perl/ch-2.pl14
3 files changed, 31 insertions, 0 deletions
diff --git a/challenge-308/wlmb/blog.txt b/challenge-308/wlmb/blog.txt
new file mode 100644
index 0000000000..4420fc8c83
--- /dev/null
+++ b/challenge-308/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2025/02/10/PWC308/
diff --git a/challenge-308/wlmb/perl/ch-1.pl b/challenge-308/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..52948bcf89
--- /dev/null
+++ b/challenge-308/wlmb/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 308
+# Task 1: Count Common
+#
+# See https://wlmb.github.io/2025/02/10/PWC308/#task-1-count-common
+use v5.36;
+die <<~"FIN" unless @ARGV==2;
+ Usage $0 S1 S2
+ to find how many words are common to the
+ space separated strings S1 and S2
+ FIN
+my @seen;
+for my $x(0,1){
+ ++$seen[$x]{$_}for split" ",$ARGV[$x];
+}
+say "s1 = $ARGV[0], s2=$ARGV[1] -> ", 0+grep{$seen[0]{$_}} keys %{$seen[1]};
diff --git a/challenge-308/wlmb/perl/ch-2.pl b/challenge-308/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..2e21f0b9dd
--- /dev/null
+++ b/challenge-308/wlmb/perl/ch-2.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 308
+# Task 2: Decode XOR
+#
+# See https://wlmb.github.io/2025/02/10/PWC308/#task-2-decode-xor
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 I E_0 E_1...E_n
+ to decode the sequence E_j=Oj^O_{j+1} and find the original sequence
+ O_j, j=0..n+1 given its starting value I
+ FIN
+push my @original, my $initial=shift;
+push @original, $original[-1]^$_ for @ARGV;
+say "initial=$initial, encoded=@ARGV -> @original"