aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-201/wlmb/blog.txt2
-rwxr-xr-xchallenge-201/wlmb/perl/ch-1.pl14
-rwxr-xr-xchallenge-201/wlmb/perl/ch-2.pl18
3 files changed, 34 insertions, 0 deletions
diff --git a/challenge-201/wlmb/blog.txt b/challenge-201/wlmb/blog.txt
new file mode 100644
index 0000000000..c62ddb9009
--- /dev/null
+++ b/challenge-201/wlmb/blog.txt
@@ -0,0 +1,2 @@
+https://wlmb.github.io/2023/01/23/PWC201/
+
diff --git a/challenge-201/wlmb/perl/ch-1.pl b/challenge-201/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..eca10fb440
--- /dev/null
+++ b/challenge-201/wlmb/perl/ch-1.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 201
+# Task 1: Missing Numbers
+#
+# See https://wlmb.github.io/2023/01/23/PWC201/#task-1-missing-numbers
+use v5.36;
+my %seen;
+die <<~ "FIN" unless @ARGV;
+ Usage: $0 N1 [N2...]
+ to find the missing numbers from the sequence N1 N2...
+ FIN
+@seen{@ARGV}=(1)x@ARGV;
+die "Expected unique values" unless 0+@ARGV==0+keys %seen;
+say join " ", @ARGV, "->", grep {!$seen{$_}} 0..@ARGV;
diff --git a/challenge-201/wlmb/perl/ch-2.pl b/challenge-201/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..9433e56350
--- /dev/null
+++ b/challenge-201/wlmb/perl/ch-2.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 201
+# Task 2: Penny Piles
+#
+# See https://wlmb.github.io/2023/01/23/PWC201/#task-2-penny-piles
+use v5.36;
+use List::Util qw(min sum);
+use Memoize;
+memoize "rows";
+die <<~"FIN" unless @ARGV;
+ Usage: $0 N1 [N2...]
+ to obtain the number of ascending rows of piles of Ni coins.
+ FIN
+say "$_->", rows($_, $_) for @ARGV;
+sub rows($coins,$max){
+ return 1 if $coins==0;
+ return sum map{rows($coins-$_,min($_, $coins-$_))} 1..min($coins, $max)
+}