From ded1adead24d65f5ba5de3c51476467b98b87253 Mon Sep 17 00:00:00 2001 From: 冯昶 Date: Tue, 12 Oct 2021 10:30:03 +0800 Subject: add more output --- challenge-134/feng-chang/raku/ch-2.raku | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } -- cgit