From 75100ccacdb6b065a46a3bd6ac9015f59d2b9ead Mon Sep 17 00:00:00 2001 From: Clive Holloway Date: Tue, 9 Apr 2019 16:11:46 -0400 Subject: solution for Challenge 2, week 3 --- challenge-003/cliveholloway/README | 1 + challenge-003/cliveholloway/perl5/ch-2.pl | 23 +++++++++++++++++++++++ members.json | 1 + 3 files changed, 25 insertions(+) create mode 100644 challenge-003/cliveholloway/README create mode 100755 challenge-003/cliveholloway/perl5/ch-2.pl 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", -- cgit