aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2020-11-23 08:49:44 -0600
committerLuis Mochan <mochan@fis.unam.mx>2020-11-23 08:49:44 -0600
commitccd62bfcbdbcce89afc8f7351b00abbb2b9d0321 (patch)
tree610cc8cf43d127ed1b747a3b59e69b70c3bc1db9
parent4f0144c47dd21aab3d330220fa78d7816a6aaaeb (diff)
downloadperlweeklychallenge-club-ccd62bfcbdbcce89afc8f7351b00abbb2b9d0321.tar.gz
perlweeklychallenge-club-ccd62bfcbdbcce89afc8f7351b00abbb2b9d0321.tar.bz2
perlweeklychallenge-club-ccd62bfcbdbcce89afc8f7351b00abbb2b9d0321.zip
Add output as comment.
-rw-r--r--challenge-088/wlmb/perl/ch-1.pl4
-rw-r--r--challenge-088/wlmb/perl/ch-2.pl5
2 files changed, 6 insertions, 3 deletions
diff --git a/challenge-088/wlmb/perl/ch-1.pl b/challenge-088/wlmb/perl/ch-1.pl
index 1abce9b7fc..fad2edcfc8 100644
--- a/challenge-088/wlmb/perl/ch-1.pl
+++ b/challenge-088/wlmb/perl/ch-1.pl
@@ -7,7 +7,9 @@ use feature qw(say);
say join " ", "Example 1:", array_of_products(5,2,1,4,3);
say join " ", "Example 2:", array_of_products(2,1,4,3);
-
+# Output:
+# Example 1: 24 60 120 30 40
+# Example 2: 12 24 6 8
sub array_of_products {
use PDL; #use the perl data language
use PDL::NiceSlice;
diff --git a/challenge-088/wlmb/perl/ch-2.pl b/challenge-088/wlmb/perl/ch-2.pl
index 18e95cead5..4cf538472b 100644
--- a/challenge-088/wlmb/perl/ch-2.pl
+++ b/challenge-088/wlmb/perl/ch-2.pl
@@ -7,12 +7,13 @@ use feature qw(say);
say join " ", "Example 1:", spiral_matrix([1,2,3],[4,5,6],[7,8,9]);
say join " ", "Example 2:", spiral_matrix([1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]);
-
+# output:
+# Example 1: 1 2 3 6 9 8 7 4 5
+# Example 2: 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
sub spiral_matrix {
use PDL; #use the perl data language
use PDL::NiceSlice;
my $input =pdl(@_); #input piddle (PDL 2D array)
- say $input;
my @output;
return if $input->dim(1)==0; # 0 rows no elements
while($input->dim(0) > 0){ #until no more columns