aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-142/luca-ferrari/blog-1.txt1
-rw-r--r--challenge-142/luca-ferrari/blog-2.txt1
-rw-r--r--challenge-142/luca-ferrari/blog-3.txt1
-rw-r--r--challenge-142/luca-ferrari/blog-4.txt1
-rw-r--r--challenge-142/luca-ferrari/postgresql/ch-1.sql20
-rw-r--r--challenge-142/luca-ferrari/postgresql/ch-2.sh7
-rw-r--r--challenge-142/luca-ferrari/raku/ch-1.p66
-rw-r--r--challenge-142/luca-ferrari/raku/ch-2.p610
8 files changed, 47 insertions, 0 deletions
diff --git a/challenge-142/luca-ferrari/blog-1.txt b/challenge-142/luca-ferrari/blog-1.txt
new file mode 100644
index 0000000000..1571806a3c
--- /dev/null
+++ b/challenge-142/luca-ferrari/blog-1.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/12/06/PerlWeeklyChallenge142.html#task1
diff --git a/challenge-142/luca-ferrari/blog-2.txt b/challenge-142/luca-ferrari/blog-2.txt
new file mode 100644
index 0000000000..0fc1e8004c
--- /dev/null
+++ b/challenge-142/luca-ferrari/blog-2.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/12/06/PerlWeeklyChallenge142.html#task2
diff --git a/challenge-142/luca-ferrari/blog-3.txt b/challenge-142/luca-ferrari/blog-3.txt
new file mode 100644
index 0000000000..dc1017883e
--- /dev/null
+++ b/challenge-142/luca-ferrari/blog-3.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/12/06/PerlWeeklyChallenge142.html#task1pg
diff --git a/challenge-142/luca-ferrari/blog-4.txt b/challenge-142/luca-ferrari/blog-4.txt
new file mode 100644
index 0000000000..d5913735fe
--- /dev/null
+++ b/challenge-142/luca-ferrari/blog-4.txt
@@ -0,0 +1 @@
+https://fluca1978.github.io/2021/12/06/PerlWeeklyChallenge142.html#task2pg
diff --git a/challenge-142/luca-ferrari/postgresql/ch-1.sql b/challenge-142/luca-ferrari/postgresql/ch-1.sql
new file mode 100644
index 0000000000..57de950651
--- /dev/null
+++ b/challenge-142/luca-ferrari/postgresql/ch-1.sql
@@ -0,0 +1,20 @@
+CREATE OR REPLACE FUNCTION
+ f_divisors_last_digit( m int, n int )
+ RETURNS SETOF int
+AS $CODE$
+ WITH RECURSIVE numbers AS (
+ SELECT 1 as num
+ UNION
+ SELECT num + 1
+ FROM numbers
+ WHERE num + 1 <= m )
+ , divisors AS (
+ SELECT num as div
+ FROM numbers
+ WHERE m % num = 0 )
+ SELECT count(*)
+ FROM divisors
+ WHERE div::text LIKE ( '%' || n::text );
+
+ $CODE$
+ LANGUAGE sql;
diff --git a/challenge-142/luca-ferrari/postgresql/ch-2.sh b/challenge-142/luca-ferrari/postgresql/ch-2.sh
new file mode 100644
index 0000000000..75ad30e1c8
--- /dev/null
+++ b/challenge-142/luca-ferrari/postgresql/ch-2.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+for i in $*; do
+ psql -At -h miguel -U luca -c "SELECT pg_sleep( $i ); SELECT $i;" testdb &
+done
+
+echo
diff --git a/challenge-142/luca-ferrari/raku/ch-1.p6 b/challenge-142/luca-ferrari/raku/ch-1.p6
new file mode 100644
index 0000000000..a2315aba80
--- /dev/null
+++ b/challenge-142/luca-ferrari/raku/ch-1.p6
@@ -0,0 +1,6 @@
+#!raku
+
+sub MAIN( Int $m where { $m > 1 }
+ , Int $n where { $n > 0 && $m > $n } ) {
+ ( 1 .. $m ).grep( $m %% * ).grep( * ~~ / ^ \d* $n $ / ).elems.say;
+}
diff --git a/challenge-142/luca-ferrari/raku/ch-2.p6 b/challenge-142/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..1989f64917
--- /dev/null
+++ b/challenge-142/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,10 @@
+#!raku
+
+sub MAIN( *@n where { @n.grep( * ~~ Int ).elems == @n.elems } ) {
+ my @threads;
+ for @n -> $sleep {
+ @threads.push: Promise.in( $sleep.Int ).then( { $sleep.say } );
+ }
+
+ await @threads;
+}