aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-10-12 10:30:03 +0800
committer冯昶 <seaker@qq.com>2021-10-12 10:30:03 +0800
commitded1adead24d65f5ba5de3c51476467b98b87253 (patch)
tree243b92c30e5de3707740035c20826496e810e352
parent1c423f3fee1b532ca610704ac3596e0ae1eeb912 (diff)
downloadperlweeklychallenge-club-ded1adead24d65f5ba5de3c51476467b98b87253.tar.gz
perlweeklychallenge-club-ded1adead24d65f5ba5de3c51476467b98b87253.tar.bz2
perlweeklychallenge-club-ded1adead24d65f5ba5de3c51476467b98b87253.zip
add more output
-rwxr-xr-xchallenge-134/feng-chang/raku/ch-2.raku6
1 files changed, 5 insertions, 1 deletions
diff --git a/challenge-134/feng-chang/raku/ch-2.raku b/challenge-134/feng-chang/raku/ch-2.raku
index 46a7e40b52..9e565720a9 100755
--- a/challenge-134/feng-chang/raku/ch-2.raku
+++ b/challenge-134/feng-chang/raku/ch-2.raku
@@ -2,6 +2,7 @@
sub MAIN(UInt:D \m, UInt:D \n) {
my @widths = (1..n)».&{ $_*m }».chars;
+ my %terms;
put 'x'.fmt("%{ m.chars }s"),
' |',
@@ -13,6 +14,9 @@ sub MAIN(UInt:D \m, UInt:D \n) {
for 1..m -> $row {
put $row.fmt("%{ m.chars }d"),
' |',
- (1..n)».&{ ($_*$row).fmt(" %{ @widths[$_-1] }d") }.join;
+ (1..n)».&{ my $i = $_*$row; ++%terms{$i}; $i.fmt(" %{ @widths[$_-1] }d") }.join;
}
+
+ put "\nDistinct Terms: ", %terms.keys».Int.sort.join(', ');
+ put 'Count: ', %terms.keys.elems;
}