aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-04-10 10:44:14 +0100
committerGitHub <noreply@github.com>2019-04-10 10:44:14 +0100
commite57020f83c26d151fc8c2d8d8475d15138cde60a (patch)
treeaeef181c1147b83a9d12a09d28d39ffa917b8961
parente18516103328caf1bd59d53c19996b3de3b8609d (diff)
parent75100ccacdb6b065a46a3bd6ac9015f59d2b9ead (diff)
downloadperlweeklychallenge-club-e57020f83c26d151fc8c2d8d8475d15138cde60a.tar.gz
perlweeklychallenge-club-e57020f83c26d151fc8c2d8d8475d15138cde60a.tar.bz2
perlweeklychallenge-club-e57020f83c26d151fc8c2d8d8475d15138cde60a.zip
Merge pull request #39 from cliveholloway/cliveholloway-challenge002
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",