From 19b5afa60dc8f36cf20b2685c715a670789ea3d7 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 10:56:35 +0100 Subject: Task 1 done --- challenge-201/luca-ferrari/raku/ch-1.p6 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 challenge-201/luca-ferrari/raku/ch-1.p6 diff --git a/challenge-201/luca-ferrari/raku/ch-1.p6 b/challenge-201/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..a83e9d6d22 --- /dev/null +++ b/challenge-201/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,18 @@ +#!raku + +# +# Perl Weekly Challenge 201 +# Task 1 +# +# See +# + +sub MAIN( *@n where { @n.grep( * ~~ Int ) == @n.elems } ) { + my @missing-numbers; + for 0 ^.. @n.elems { + @missing-numbers.push: $_ if ( ! @n.grep( $_ ) ); + } + + @missing-numbers.join( ', ' ).say; + +} -- cgit From 1fb53cd5a5a8ed5e4d84e27def94276b2689e4e6 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 12:00:42 +0100 Subject: Task 2 done --- challenge-201/luca-ferrari/raku/ch-2.p6 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 challenge-201/luca-ferrari/raku/ch-2.p6 diff --git a/challenge-201/luca-ferrari/raku/ch-2.p6 b/challenge-201/luca-ferrari/raku/ch-2.p6 new file mode 100644 index 0000000000..9ab1bd4e12 --- /dev/null +++ b/challenge-201/luca-ferrari/raku/ch-2.p6 @@ -0,0 +1,14 @@ +#!raku + +# +# Perl Weekly Challenge 201 +# Task 2 +# +# See +# + +use Math::Combinatorics ; + +sub MAIN( Int $n where { $n > 0 } ) { + say partitions( $n ).elems; +} -- cgit From cca26026017118bac3100c2d344e5bea55a31592 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 12:06:19 +0100 Subject: Task 1 plperl done --- challenge-201/luca-ferrari/postgresql/ch-1.plperl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 challenge-201/luca-ferrari/postgresql/ch-1.plperl diff --git a/challenge-201/luca-ferrari/postgresql/ch-1.plperl b/challenge-201/luca-ferrari/postgresql/ch-1.plperl new file mode 100644 index 0000000000..747396c908 --- /dev/null +++ b/challenge-201/luca-ferrari/postgresql/ch-1.plperl @@ -0,0 +1,21 @@ +-- +-- Perl Weekly Challenge 201 +-- Task 1 +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc201; + +CREATE OR REPLACE FUNCTION +pwc201.task1_plperl( int[] ) +RETURNS SETOF int +AS $CODE$ + my ( $n ) = @_; + + for my $needle ( 1 .. $n->@* ) { + return_next( $needle ) if ( ! grep( { $_ == $needle } $n->@* ) ); + } + +return; +$CODE$ +LANGUAGE plperl; -- cgit From 8316342281a4642aeb196c8d12683fc9dd01c5c4 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 12:09:21 +0100 Subject: Task 2 plperl done --- challenge-201/luca-ferrari/postgresql/ch-2.plperl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 challenge-201/luca-ferrari/postgresql/ch-2.plperl diff --git a/challenge-201/luca-ferrari/postgresql/ch-2.plperl b/challenge-201/luca-ferrari/postgresql/ch-2.plperl new file mode 100644 index 0000000000..68cfb36d32 --- /dev/null +++ b/challenge-201/luca-ferrari/postgresql/ch-2.plperl @@ -0,0 +1,20 @@ +-- +-- Perl Weekly Challenge 201 +-- Task 2 +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc201; + +CREATE OR REPLACE FUNCTION +pwc201.task2_plperl( int) +RETURNS int +AS $CODE$ + + use Integer::Partition; + my $partitions = Integer::Partition->new( $_[0] ); + my $count = 0; + $count++ while( $partitions->next ); + return $count; +$CODE$ +LANGUAGE plperlu; -- cgit From cee1163da54b67d4de0d0b99f983d8fd21f2bab1 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 12:13:30 +0100 Subject: Task 1 sql done --- challenge-201/luca-ferrari/postgresql/ch-1.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-201/luca-ferrari/postgresql/ch-1.sql diff --git a/challenge-201/luca-ferrari/postgresql/ch-1.sql b/challenge-201/luca-ferrari/postgresql/ch-1.sql new file mode 100644 index 0000000000..17597a8b88 --- /dev/null +++ b/challenge-201/luca-ferrari/postgresql/ch-1.sql @@ -0,0 +1,19 @@ +-- +-- Perl Weekly Challenge 201 +-- Task 1 +-- +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc201; + +CREATE OR REPLACE FUNCTION +pwc201.task1_plpgsql( n int[] ) +RETURNS SETOF int +AS $CODE$ + SELECT v + FROM generate_series( 1, array_length( n, 1 ) ) v + WHERE v NOT IN + ( SELECT unnest( n ) ); +$CODE$ +LANGUAGE sql; -- cgit From d532740fe117f48b593a5abfc3761e9b45e73c26 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 12:14:44 +0100 Subject: Task 2 sql done --- challenge-201/luca-ferrari/postgresql/ch-2.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 challenge-201/luca-ferrari/postgresql/ch-2.sql diff --git a/challenge-201/luca-ferrari/postgresql/ch-2.sql b/challenge-201/luca-ferrari/postgresql/ch-2.sql new file mode 100644 index 0000000000..9e2afdb404 --- /dev/null +++ b/challenge-201/luca-ferrari/postgresql/ch-2.sql @@ -0,0 +1,16 @@ +-- +-- Perl Weekly Challenge 201 +-- Task 2 +-- +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc201; + +CREATE OR REPLACE FUNCTION +pwc201.task2_plpgsql( n int ) +RETURNS int +AS $CODE$ + SELECT pwc201.task2_plperl( n ); +$CODE$ +LANGUAGE sql; -- cgit From 3aee3b3dfd19d9012a3b009545b60b6bb0c5565d Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 23 Jan 2023 17:55:10 +0100 Subject: Blog references --- challenge-201/luca-ferrari/blog-1.txt | 1 + challenge-201/luca-ferrari/blog-2.txt | 1 + challenge-201/luca-ferrari/blog-3.txt | 1 + challenge-201/luca-ferrari/blog-4.txt | 1 + challenge-201/luca-ferrari/blog-5.txt | 1 + challenge-201/luca-ferrari/blog-6.txt | 1 + 6 files changed, 6 insertions(+) create mode 100644 challenge-201/luca-ferrari/blog-1.txt create mode 100644 challenge-201/luca-ferrari/blog-2.txt create mode 100644 challenge-201/luca-ferrari/blog-3.txt create mode 100644 challenge-201/luca-ferrari/blog-4.txt create mode 100644 challenge-201/luca-ferrari/blog-5.txt create mode 100644 challenge-201/luca-ferrari/blog-6.txt diff --git a/challenge-201/luca-ferrari/blog-1.txt b/challenge-201/luca-ferrari/blog-1.txt new file mode 100644 index 0000000000..8194ccff39 --- /dev/null +++ b/challenge-201/luca-ferrari/blog-1.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task1 diff --git a/challenge-201/luca-ferrari/blog-2.txt b/challenge-201/luca-ferrari/blog-2.txt new file mode 100644 index 0000000000..d27370c7ac --- /dev/null +++ b/challenge-201/luca-ferrari/blog-2.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task2 diff --git a/challenge-201/luca-ferrari/blog-3.txt b/challenge-201/luca-ferrari/blog-3.txt new file mode 100644 index 0000000000..712de62e43 --- /dev/null +++ b/challenge-201/luca-ferrari/blog-3.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task1plperl diff --git a/challenge-201/luca-ferrari/blog-4.txt b/challenge-201/luca-ferrari/blog-4.txt new file mode 100644 index 0000000000..2175d4ccb3 --- /dev/null +++ b/challenge-201/luca-ferrari/blog-4.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task2plperl diff --git a/challenge-201/luca-ferrari/blog-5.txt b/challenge-201/luca-ferrari/blog-5.txt new file mode 100644 index 0000000000..6f2d6d3f1b --- /dev/null +++ b/challenge-201/luca-ferrari/blog-5.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task1plpgsql diff --git a/challenge-201/luca-ferrari/blog-6.txt b/challenge-201/luca-ferrari/blog-6.txt new file mode 100644 index 0000000000..c8eeb6cc57 --- /dev/null +++ b/challenge-201/luca-ferrari/blog-6.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/01/23/PerlWeeklyChallenge201.html#task2plpgsql -- cgit