diff options
| -rw-r--r-- | challenge-134/luca-ferrari/blog-1.txt | 1 | ||||
| -rw-r--r-- | challenge-134/luca-ferrari/blog-2.txt | 1 | ||||
| -rw-r--r-- | challenge-134/luca-ferrari/raku/ch-1.p6 | 20 | ||||
| -rw-r--r-- | challenge-134/luca-ferrari/raku/ch-2.p6 | 34 |
4 files changed, 56 insertions, 0 deletions
diff --git a/challenge-134/luca-ferrari/blog-1.txt b/challenge-134/luca-ferrari/blog-1.txt new file mode 100644 index 0000000000..bc163279b2 --- /dev/null +++ b/challenge-134/luca-ferrari/blog-1.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2021/10/11/PerlWeeklyChallegne133.html#task1 diff --git a/challenge-134/luca-ferrari/blog-2.txt b/challenge-134/luca-ferrari/blog-2.txt new file mode 100644 index 0000000000..65f4a25e54 --- /dev/null +++ b/challenge-134/luca-ferrari/blog-2.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2021/10/11/PerlWeeklyChallegne133.html#task2 diff --git a/challenge-134/luca-ferrari/raku/ch-1.p6 b/challenge-134/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..ef7c25b62c --- /dev/null +++ b/challenge-134/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,20 @@ +#!raku + + +sub MAIN( Int $limit where { $limit > 0 } = 5 ) { + my @digits = 1 .. 9; + @digits.push: 0; + my $start = @digits.join; + + my @pandigital = lazy gather { + for $start ..^ Inf -> $current { + next if $start ~~ / ^0+ /; + my $found = 0; + $found += $current.comb.grep( $_ ).so ?? 1 !! 0 for @digits; + take $current if $found >= @digits.elems; + } + } + + @pandigital[ $_ ].say for 0 ..^ $limit; + +} diff --git a/challenge-134/luca-ferrari/raku/ch-2.p6 b/challenge-134/luca-ferrari/raku/ch-2.p6 new file mode 100644 index 0000000000..5538af30b1 --- /dev/null +++ b/challenge-134/luca-ferrari/raku/ch-2.p6 @@ -0,0 +1,34 @@ +#!raku + + +sub MAIN( Int $cols where { $cols > 0 } = 5, Int $rows where { $rows > 0 } = 3 ) { + my @table; + my @distinct; + + # table header + " x\t|\t".print; + ( 1 .. $cols ).join( "\t" ).say; + "--------|--------".print; + ( "-" x 8 x $cols ).say; + + + + + for 1 .. $rows -> $current-row { + for 1 .. $cols -> $current-col { + my $value = $current-row * $current-col; + @table[ $current-row - 1 ].push: $value; + @distinct.push: $value if ! @distinct.grep( $value ); + } + } + + # print the table + for 1 .. $rows { + " $_\t|\t".print; + @table[ $_ - 1 ].join( "\t" ).say; + } + + "\nDistinct values: ".say; + @distinct.join( ', ' ).say; + +} |
