aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-02-10 13:46:59 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-02-10 13:46:59 -0600
commitcf09e8b28196791107caad4bd70eb159cfc7a545 (patch)
tree76e5a059d52bd9f25e65122b9b8e54f78e277af3
parentaa4b8399bdb3da0a50173fcab689bfa80b9b54e1 (diff)
downloadperlweeklychallenge-club-cf09e8b28196791107caad4bd70eb159cfc7a545.tar.gz
perlweeklychallenge-club-cf09e8b28196791107caad4bd70eb159cfc7a545.tar.bz2
perlweeklychallenge-club-cf09e8b28196791107caad4bd70eb159cfc7a545.zip
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"