diff options
| -rw-r--r-- | challenge-134/simon-proctor/raku/ch-1.raku | 6 | ||||
| -rw-r--r-- | challenge-134/simon-proctor/raku/ch-2.raku | 22 |
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-134/simon-proctor/raku/ch-1.raku b/challenge-134/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..e7cc2e38f3 --- /dev/null +++ b/challenge-134/simon-proctor/raku/ch-1.raku @@ -0,0 +1,6 @@ +#!/usr/bin/env raku + +#| Find the first n (default 5) Pandigital Numbers in Base 10 +sub MAIN ( UInt \n = 5 ) { + .say for (1023456789..*).grep( { $_.comb (==) ('0'..'9')} )[^n]; +} diff --git a/challenge-134/simon-proctor/raku/ch-2.raku b/challenge-134/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..dd34faa858 --- /dev/null +++ b/challenge-134/simon-proctor/raku/ch-2.raku @@ -0,0 +1,22 @@ +#!/usr/bin/env raku + +#| Given a pair of integers m and n draw a mulitplication grid and count the number of unique numbers +sub MAIN( UInt \m, UInt \n ) { + my \max-width = ( m*n ).codes; + my \max-val = (m,n).max; + my @seen; + + # Header + say (sprintf '%*s ', max-width, 'x') ~ "|" ~ (1..m).map( { sprintf "%*s", max-width, $_ } ).join(' '); + # Divider + say ('-' x max-width + 1) ~ ( ('-' x max-width + 1) x m ); + # Rows + for (1..n) -> \i { + my @row = (1..m).map( { $_ * i } ); + push @seen, |@row; + say (sprintf '%*s ', max-width, i) ~ '|' ~ @row.map( { sprintf "%*s", max-width, $_ } ).join(' '); + } + my \distinct = @seen.Set; + say 'Distinct Terms: ' ~ distinct.keys.sort.join(', '); + say 'Count: ' ~ distinct.elems; +} |
