aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-003/jo-37/perl/ch-2.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-003/jo-37/perl/ch-2.pl b/challenge-003/jo-37/perl/ch-2.pl
new file mode 100755
index 0000000000..ae26b799c4
--- /dev/null
+++ b/challenge-003/jo-37/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+
+use v5.16;
+use warnings;
+use List::MoreUtils 'slide';
+
+
+### Implementation
+# First row is a single one.
+# In the following rows, each element is the sum of the two elements
+# from the row above, where this is embedded between two zeroes.
+
+main: {
+ my @row = (1);
+ for (1 .. shift) {
+ say "@row";
+ @row = slide {$a + $b} 0, @row, 0;
+ }
+}