aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-134/abigail/README.md1
-rw-r--r--challenge-134/abigail/perl/ch-1.pl36
-rw-r--r--challenge-134/abigail/perl/ch-2.pl46
3 files changed, 82 insertions, 1 deletions
diff --git a/challenge-134/abigail/README.md b/challenge-134/abigail/README.md
index d51d3d73e2..aa835b7f1e 100644
--- a/challenge-134/abigail/README.md
+++ b/challenge-134/abigail/README.md
@@ -6,5 +6,4 @@
## Part 2
-* [C](c/ch-2.c)
* [Perl](perl/ch-2.pl)
diff --git a/challenge-134/abigail/perl/ch-1.pl b/challenge-134/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..b04f5958bb
--- /dev/null
+++ b/challenge-134/abigail/perl/ch-1.pl
@@ -0,0 +1,36 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+#
+# See ../README.md
+#
+
+#
+# Run as: perl ch-1.pl
+#
+
+#
+# The first 40320 (= 8!) pandigital numbers in base 10 are 10 digits long,
+# all starting with '10'. The other 8 digits are all the permutations of
+# of the digits 2 .. 8.
+#
+# So, to generate the first 5 of them, we start with the first one,
+# 1023456789, chop of the last three digits (7, 8, 9), get all the
+# 6 (= 3!) permutations, sort them, throw away the last, and put them
+# after the first six digits.
+#
+
+#
+# 6 permutations, we can easily do by hand. That's quicker then searching
+# on CPAN for a module which does the work for us.
+#
+
+say "1023456$_" for qw [789 798 879 897 978];
diff --git a/challenge-134/abigail/perl/ch-2.pl b/challenge-134/abigail/perl/ch-2.pl
new file mode 100644
index 0000000000..3911a034ba
--- /dev/null
+++ b/challenge-134/abigail/perl/ch-2.pl
@@ -0,0 +1,46 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+#
+# See ../README.md
+#
+
+#
+# Run as: perl ch-2.pl < input-file
+#
+
+#
+# It's not clear what actually needs to be outputted here.
+# The challenges asks to generate a multiplication table, but to
+# display a count. But the output of the examples shows a table,
+# a list of distinct numbers, and a count of said list.
+#
+# It's often that the challenge it totally unclear where the
+# boundary is between "this is output we expect", and "this is us
+# explaining how to get that output".
+#
+# So, we will just display a count, as that is what is asked for us.
+# Wnat more? Spend a few more seconds on writing the challenge.
+#
+
+#
+# We'll just multiply all the numbers 1 <= $x <= $n with all the numbers
+# 1 <= $y <= $m, stick them in a hash, and display the number of different
+# keys in the resulting hash.
+#
+
+while (<>) {
+ ($~, $=) = split;
+ %~ = map {$; = $_; map {$; * $_ => 1} 1 .. $~} 1 .. $=;
+ say ~~%~;
+}
+
+__END__