aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-10-11 12:39:42 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-10-11 12:39:42 +0100
commit56736b75366c72f48ff238fe217b6d67e533b803 (patch)
tree01a85a677b70d4d8cc68f6b9973660c08d0598f2
parent7f103dc8430b8194e2d5d96c5d675a9d9fff20f2 (diff)
parent569133173c96ad5b2d391b58931f0bcdcb5d108b (diff)
downloadperlweeklychallenge-club-56736b75366c72f48ff238fe217b6d67e533b803.tar.gz
perlweeklychallenge-club-56736b75366c72f48ff238fe217b6d67e533b803.tar.bz2
perlweeklychallenge-club-56736b75366c72f48ff238fe217b6d67e533b803.zip
Merge branch 'fluca1978-pwc133'
-rw-r--r--challenge-134/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-134/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-134/luca-ferrari/raku/ch-1.p620
-rw-r--r--challenge-134/luca-ferrari/raku/ch-2.p634
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;
+
+}