aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}