aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-11-10 22:17:54 +0000
committerGitHub <noreply@github.com>2019-11-10 22:17:54 +0000
commit53f75bc2021d8bc3f73f08b3fc1c62a1a53ebc84 (patch)
treed0f943859988732d3df19e64b3f2579e60f1b4e3
parent59ab84bba319503e12fa3603284f66a71eb2d053 (diff)
parentab803081e3008647de2b5925ca82f627a85372c0 (diff)
downloadperlweeklychallenge-club-53f75bc2021d8bc3f73f08b3fc1c62a1a53ebc84.tar.gz
perlweeklychallenge-club-53f75bc2021d8bc3f73f08b3fc1c62a1a53ebc84.tar.bz2
perlweeklychallenge-club-53f75bc2021d8bc3f73f08b3fc1c62a1a53ebc84.zip
Merge pull request #926 from mienaikage/033-2-raku
Add Raku solution for challenge-033-2
-rwxr-xr-xchallenge-033/daniel-mita/perl6/ch-2.p628
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-033/daniel-mita/perl6/ch-2.p6 b/challenge-033/daniel-mita/perl6/ch-2.p6
new file mode 100755
index 0000000000..a91912a2e4
--- /dev/null
+++ b/challenge-033/daniel-mita/perl6/ch-2.p6
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl6
+
+#| Prints a multiplication table with only the top half of the triangle
+sub MAIN (
+ Int $max where * > 0 = 11, #= The max number of the multiplication table (defaults to 11)
+ --> Nil
+) {
+ my @range = 1 .. $max;
+ my $spacing = @range[*-1]².chars + 1;
+
+ print ' x|';
+ print sprintf('%' ~ $spacing ~ 's', $_) for @range;
+ print "\n";
+ print '--+';
+ say [x] «
+ -
+ $spacing
+ @range.elems()
+ »;
+
+ for @range -> $a {
+ print sprintf('%2s|', $a);
+ for @range -> $b {
+ print sprintf('%' ~ $spacing ~ 's', $a ≤ $b ?? $a * $b !! '');
+ }
+ print "\n";
+ }
+}