aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClive Holloway <clive.holloway@gmail.com>2019-04-09 16:11:46 -0400
committerClive Holloway <clive.holloway@gmail.com>2019-04-09 16:11:46 -0400
commit75100ccacdb6b065a46a3bd6ac9015f59d2b9ead (patch)
tree8227dae8502cc86c0f80a91ddc99bb7a106a00bc
parent46e6fd17e344dc68db086512faf91841035e4ba4 (diff)
downloadperlweeklychallenge-club-75100ccacdb6b065a46a3bd6ac9015f59d2b9ead.tar.gz
perlweeklychallenge-club-75100ccacdb6b065a46a3bd6ac9015f59d2b9ead.tar.bz2
perlweeklychallenge-club-75100ccacdb6b065a46a3bd6ac9015f59d2b9ead.zip
solution for Challenge 2, week 3
-rw-r--r--challenge-003/cliveholloway/README1
-rwxr-xr-xchallenge-003/cliveholloway/perl5/ch-2.pl23
-rw-r--r--members.json1
3 files changed, 25 insertions, 0 deletions
diff --git a/challenge-003/cliveholloway/README b/challenge-003/cliveholloway/README
new file mode 100644
index 0000000000..b69201296e
--- /dev/null
+++ b/challenge-003/cliveholloway/README
@@ -0,0 +1 @@
+Solution by Clive Holloway
diff --git a/challenge-003/cliveholloway/perl5/ch-2.pl b/challenge-003/cliveholloway/perl5/ch-2.pl
new file mode 100755
index 0000000000..be67bd4673
--- /dev/null
+++ b/challenge-003/cliveholloway/perl5/ch-2.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use v5.012;
+
+my @out=([1],[1,1]);
+
+for (3..$ARGV[0]) {
+ my @new_row=(1,@{$out[-1]});
+ for (1..$#{$out[-1]}) {
+ $new_row[$_] = $out[-1][$_-1] + $out[-1][$_];
+ }
+ push @out, \@new_row;
+}
+
+# format data for output - obviously you'll run out of terminal at some point,
+# so, this is just a pretty demo output
+my $longest_length = length("@{$out[-1]}");
+for (0..$#out) {
+ $out[$_] = "@{$out[$_]}";
+ my $this_length = length($out[$_]);
+ say ' 'x(($longest_length-$this_length)/2).$out[$_];
+}
diff --git a/members.json b/members.json
index 4673a209f8..715990fb11 100644
--- a/members.json
+++ b/members.json
@@ -13,6 +13,7 @@
"aubrey-quarcoo" : "Aubrey Quarcoo",
"bill-palmer" : "Bill Palmer",
"bob-kleemann" : "Bob Kleemann",
+ "cliveholloway" : "Clive Holloway",
"daniel-mantovani" : "Daniel Mantovani",
"dave-cross" : "Dave Cross",
"dave-jacoby" : "Dave Jacoby",