aboutsummaryrefslogtreecommitdiff
path: root/challenge-080
diff options
context:
space:
mode:
authorJulio <julio.dcs@gmail.com>2020-09-30 00:15:46 +0200
committerJulio <julio.dcs@gmail.com>2020-09-30 00:15:46 +0200
commit6491c338d050e1b58e7ff24ef9191b16b6756769 (patch)
treec4135de92009ee9da643c2122b14808a91f6a8f1 /challenge-080
parentaa14cbf8342e04b936f40bcc720a23a258137ecd (diff)
downloadperlweeklychallenge-club-6491c338d050e1b58e7ff24ef9191b16b6756769.tar.gz
perlweeklychallenge-club-6491c338d050e1b58e7ff24ef9191b16b6756769.tar.bz2
perlweeklychallenge-club-6491c338d050e1b58e7ff24ef9191b16b6756769.zip
Add solution for Week 80
Diffstat (limited to 'challenge-080')
-rw-r--r--challenge-080/juliodcs/perl/ch-1.pl15
-rw-r--r--challenge-080/juliodcs/perl/ch-2.pl9
-rw-r--r--challenge-080/juliodcs/raku/ch-1.raku8
-rw-r--r--challenge-080/juliodcs/raku/ch-2.raku3
4 files changed, 35 insertions, 0 deletions
diff --git a/challenge-080/juliodcs/perl/ch-1.pl b/challenge-080/juliodcs/perl/ch-1.pl
new file mode 100644
index 0000000000..be58e7913d
--- /dev/null
+++ b/challenge-080/juliodcs/perl/ch-1.pl
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+use List::MoreUtils qw(uniq);
+use feature 'say';
+use bigint;
+
+sub min_slot {
+ my $expected = 1;
+ for my $number ( uniq sort {$a - $b} grep {$_ > 0} @ARGV ) {
+ return --$expected if $expected++ != $number;
+ }
+ return 0; # no empty *slot*
+}
+
+say 'Min slot: ' . min_slot;
diff --git a/challenge-080/juliodcs/perl/ch-2.pl b/challenge-080/juliodcs/perl/ch-2.pl
new file mode 100644
index 0000000000..ee281800b8
--- /dev/null
+++ b/challenge-080/juliodcs/perl/ch-2.pl
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use experimental 'signatures';
+use List::Util qw(all);
+use feature 'say';
+
+die "Only numbers accepted\n" unless all { m/^\d+$/ } @ARGV;
+
+say @ARGV + grep { $ARGV[$_] ne $ARGV[$_ + 1] } 0 .. @ARGV - 2;
diff --git a/challenge-080/juliodcs/raku/ch-1.raku b/challenge-080/juliodcs/raku/ch-1.raku
new file mode 100644
index 0000000000..6e0e291735
--- /dev/null
+++ b/challenge-080/juliodcs/raku/ch-1.raku
@@ -0,0 +1,8 @@
+sub min-slot {
+ for @*ARGS>>.Int.grep(* > 0).sort.unique.pairs {
+ return .key.succ if .key.succ != .value;
+ }
+ return 0 # no empty *slot*
+}
+
+say 'Min slot: ' ~ min-slot;
diff --git a/challenge-080/juliodcs/raku/ch-2.raku b/challenge-080/juliodcs/raku/ch-2.raku
new file mode 100644
index 0000000000..c74f184fc7
--- /dev/null
+++ b/challenge-080/juliodcs/raku/ch-2.raku
@@ -0,0 +1,3 @@
+my @N = @*ARGS>>.Int;
+
+say @N.elems + elems (^@N.elems.pred).grep: { @N[$_] != @N[.succ] };