aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-217/luca-ferrari/postgresql/ch-2.plperl22
1 files changed, 22 insertions, 0 deletions
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 <https://perlweeklychallenge.org/blog/perl-weekly-challenge-217/>
+--
+
+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;