From cbacf4a375d577a64c304a3bf314963fd158430a Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 07:59:00 +0200 Subject: Task 1 done --- challenge-217/luca-ferrari/raku/ch-1.p6 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 challenge-217/luca-ferrari/raku/ch-1.p6 diff --git a/challenge-217/luca-ferrari/raku/ch-1.p6 b/challenge-217/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..a124f2d0a5 --- /dev/null +++ b/challenge-217/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,12 @@ +#!raku + +# +# Perl Weekly Challenge 217 +# Task 1 +# +# See +# + +sub MAIN( *@n where { @n.grep( * ~~ Int ).elems == @n.elems } ) { + @n.sort()[ 3 ].say; +} -- cgit From 1e3cc0931bbc57e978cd4991807ac9d7a846e270 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 08:01:31 +0200 Subject: Task 2 done --- challenge-217/luca-ferrari/raku/ch-2.p6 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 challenge-217/luca-ferrari/raku/ch-2.p6 diff --git a/challenge-217/luca-ferrari/raku/ch-2.p6 b/challenge-217/luca-ferrari/raku/ch-2.p6 new file mode 100644 index 0000000000..e765c6480c --- /dev/null +++ b/challenge-217/luca-ferrari/raku/ch-2.p6 @@ -0,0 +1,17 @@ +#!raku + +# +# Perl Weekly Challenge 217 +# Task 2 +# +# See +# + +sub MAIN( *@list where { @list.grep( * ~~ Int ).elems == @list.elems } ) { + my $max = 0; + for @list.permutations { + $max = $_.join if ( $_.join.Int > $max ); + } + + $max.say; +} -- cgit From 5bc6b4f50d9bc898ce10d6baf8ac7fd0d7515e2e Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 08:31:08 +0200 Subject: Task 1 plperl done --- challenge-217/luca-ferrari/postgresql/ch-1.plperl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 challenge-217/luca-ferrari/postgresql/ch-1.plperl diff --git a/challenge-217/luca-ferrari/postgresql/ch-1.plperl b/challenge-217/luca-ferrari/postgresql/ch-1.plperl new file mode 100644 index 0000000000..7e470898c1 --- /dev/null +++ b/challenge-217/luca-ferrari/postgresql/ch-1.plperl @@ -0,0 +1,16 @@ +-- +-- Perl Weekly Challenge 217 +-- Task 1 +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc217; + +CREATE OR REPLACE FUNCTION +pwc217.task1_plperl( int[] ) +RETURNS int +AS $CODE$ + my ( $array ) = @_; + return ( sort( $array->@* ) )[ 3 ]; +$CODE$ +LANGUAGE plperl; -- cgit From fc32bb6575d9df08fd456001d6074a67a4201514 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 08:35:22 +0200 Subject: Task 2 plperl done --- challenge-217/luca-ferrari/postgresql/ch-2.plperl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 challenge-217/luca-ferrari/postgresql/ch-2.plperl diff --git a/challenge-217/luca-ferrari/postgresql/ch-2.plperl b/challenge-217/luca-ferrari/postgresql/ch-2.plperl new file mode 100644 index 0000000000..d722bcba46 --- /dev/null +++ b/challenge-217/luca-ferrari/postgresql/ch-2.plperl @@ -0,0 +1,22 @@ +-- +-- Perl Weekly Challenge 217 +-- Task 2 +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc217; + +CREATE OR REPLACE FUNCTION +pwc217.task2_plperl( int[] ) +RETURNS int +AS $CODE$ + use List::Permutor; + my ( $max ) = 0; + my $engine = List::Permutor->new( $_[0]->@* ); + while ( my @current = $engine->next ) { + $max = join( '', @current ) if ( join( '', @current ) > $max ); + } + + return $max; +$CODE$ +LANGUAGE plperlu; -- cgit From 655b6e67c6b081aa03d125605a7e607e22bc04d7 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 08:37:29 +0200 Subject: Task 1 plpgsql done --- challenge-217/luca-ferrari/postgresql/ch-1.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 challenge-217/luca-ferrari/postgresql/ch-1.sql diff --git a/challenge-217/luca-ferrari/postgresql/ch-1.sql b/challenge-217/luca-ferrari/postgresql/ch-1.sql new file mode 100644 index 0000000000..e4419e71c9 --- /dev/null +++ b/challenge-217/luca-ferrari/postgresql/ch-1.sql @@ -0,0 +1,20 @@ +-- +-- Perl Weekly Challenge 217 +-- Task 1 +-- +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc217; + +CREATE OR REPLACE FUNCTION +pwc217.task1_plpgsql( a int[] ) +RETURNS int +AS $CODE$ + SELECT v + FROM unnest( a ) v + ORDER BY 1 + LIMIT 1 + OFFSET 3; +$CODE$ +LANGUAGE sql; -- cgit From 9d756c802f1314ebb3321cda8cb9a11a85bd85c7 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 May 2023 08:45:44 +0200 Subject: Task 2 plpgsql done --- challenge-217/luca-ferrari/postgresql/ch-2.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-217/luca-ferrari/postgresql/ch-2.sql diff --git a/challenge-217/luca-ferrari/postgresql/ch-2.sql b/challenge-217/luca-ferrari/postgresql/ch-2.sql new file mode 100644 index 0000000000..e41dae8834 --- /dev/null +++ b/challenge-217/luca-ferrari/postgresql/ch-2.sql @@ -0,0 +1,19 @@ +-- +-- Perl Weekly Challenge 217 +-- Task 2 +-- +-- See +-- + +CREATE SCHEMA IF NOT EXISTS pwc217; + +CREATE OR REPLACE FUNCTION +pwc217.task2_plpgsql( a int[] ) +RETURNS int +AS $CODE$ + SELECT string_agg( v.vv::text, '' )::int + FROM ( SELECT vv + FROM unnest( a ) vv + ORDER BY ( vv % 10 ) DESC ) v; +$CODE$ +LANGUAGE sql; -- cgit From c6617352b7a486a8179e327072aa550ee7440c61 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Tue, 16 May 2023 13:47:34 +0200 Subject: Blog refernces --- challenge-217/luca-ferrari/blog-1.txt | 1 + challenge-217/luca-ferrari/blog-2.txt | 1 + challenge-217/luca-ferrari/blog-3.txt | 1 + challenge-217/luca-ferrari/blog-4.txt | 1 + challenge-217/luca-ferrari/blog-5.txt | 1 + challenge-217/luca-ferrari/blog-6.txt | 1 + 6 files changed, 6 insertions(+) create mode 100644 challenge-217/luca-ferrari/blog-1.txt create mode 100644 challenge-217/luca-ferrari/blog-2.txt create mode 100644 challenge-217/luca-ferrari/blog-3.txt create mode 100644 challenge-217/luca-ferrari/blog-4.txt create mode 100644 challenge-217/luca-ferrari/blog-5.txt create mode 100644 challenge-217/luca-ferrari/blog-6.txt diff --git a/challenge-217/luca-ferrari/blog-1.txt b/challenge-217/luca-ferrari/blog-1.txt new file mode 100644 index 0000000000..bfd82f541e --- /dev/null +++ b/challenge-217/luca-ferrari/blog-1.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task1 diff --git a/challenge-217/luca-ferrari/blog-2.txt b/challenge-217/luca-ferrari/blog-2.txt new file mode 100644 index 0000000000..7b71b89501 --- /dev/null +++ b/challenge-217/luca-ferrari/blog-2.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task2 diff --git a/challenge-217/luca-ferrari/blog-3.txt b/challenge-217/luca-ferrari/blog-3.txt new file mode 100644 index 0000000000..a25407a30b --- /dev/null +++ b/challenge-217/luca-ferrari/blog-3.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task1plperl diff --git a/challenge-217/luca-ferrari/blog-4.txt b/challenge-217/luca-ferrari/blog-4.txt new file mode 100644 index 0000000000..9554036bc0 --- /dev/null +++ b/challenge-217/luca-ferrari/blog-4.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task2plperl diff --git a/challenge-217/luca-ferrari/blog-5.txt b/challenge-217/luca-ferrari/blog-5.txt new file mode 100644 index 0000000000..0da9ad7f09 --- /dev/null +++ b/challenge-217/luca-ferrari/blog-5.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task1plpgsql diff --git a/challenge-217/luca-ferrari/blog-6.txt b/challenge-217/luca-ferrari/blog-6.txt new file mode 100644 index 0000000000..2da27b3afd --- /dev/null +++ b/challenge-217/luca-ferrari/blog-6.txt @@ -0,0 +1 @@ +https://fluca1978.github.io/2023/05/15/PerlWeeklyChallenge217.html#task2plpgsql -- cgit