aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-268/wlmb/blog.txt1
-rwxr-xr-xchallenge-268/wlmb/perl/ch-1.pl16
-rwxr-xr-xchallenge-268/wlmb/perl/ch-2.pl17
3 files changed, 34 insertions, 0 deletions
diff --git a/challenge-268/wlmb/blog.txt b/challenge-268/wlmb/blog.txt
new file mode 100644
index 0000000000..3ea74b1f37
--- /dev/null
+++ b/challenge-268/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2024/05/06/PWC268/
diff --git a/challenge-268/wlmb/perl/ch-1.pl b/challenge-268/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..62f723eb20
--- /dev/null
+++ b/challenge-268/wlmb/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 268
+# Task 1: Magic Number
+#
+# See https://wlmb.github.io/2024/05/06/PWC268/#task-1-magic-number
+use v5.36;
+use PDL;
+die <<~"FIN" unless @ARGV==2;
+ Usage: $0 X Y
+ where X is "[x1 x2...]" and Y=[y1 y2...]
+ to find the magic number M which added to the elements
+ of X yields the elements of Y
+ FIN
+my ($x,$y)=map{pdl $_}@ARGV;
+my (undef, $values)=($y->qsort-$x->qsort)->rle;
+say "@ARGV -> ", $values->dim(0)==1?$values:"None"
diff --git a/challenge-268/wlmb/perl/ch-2.pl b/challenge-268/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..7f0fac4262
--- /dev/null
+++ b/challenge-268/wlmb/perl/ch-2.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 268
+# Task 2: Number Game
+#
+# See https://wlmb.github.io/2024/05/06/PWC268/#task-2-number-game
+use v5.36;
+use experimental qw(for_list);
+die <<~"FIN" unless @ARGV and @ARGV%2==0;
+ Usage: $0 N1 N2... N2m
+ to print array even sized array N1..N2m in zig-zag order
+ (decreasing pairs of increasing value)
+ FIN
+my @result;
+for my($x, $y)(sort {$a<=>$b} @ARGV){
+ push @result, sort{$b<=>$a}($x,$y)
+}
+say "@ARGV -> @result";