aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormimosinnet <mimosinnet@gmail.com>2020-12-20 20:32:45 +0100
committermimosinnet <mimosinnet@gmail.com>2020-12-20 20:32:45 +0100
commitbeed234cd429dde9e035570337cd6415f463dabb (patch)
tree002070eb7d581be81c656729e6e2526619a3af45
parent213a75ae082e83a3da6e37114a7c4fbf243b8d09 (diff)
downloadperlweeklychallenge-club-beed234cd429dde9e035570337cd6415f463dabb.tar.gz
perlweeklychallenge-club-beed234cd429dde9e035570337cd6415f463dabb.tar.bz2
perlweeklychallenge-club-beed234cd429dde9e035570337cd6415f463dabb.zip
Challenge 091
-rw-r--r--challenge-091/mimosinnet/README1
-rw-r--r--challenge-091/mimosinnet/raku/ch-1.raku17
-rw-r--r--challenge-091/mimosinnet/raku/ch-2.raku29
3 files changed, 47 insertions, 0 deletions
diff --git a/challenge-091/mimosinnet/README b/challenge-091/mimosinnet/README
new file mode 100644
index 0000000000..773db2c2f0
--- /dev/null
+++ b/challenge-091/mimosinnet/README
@@ -0,0 +1 @@
+Solution by mimosinnet
diff --git a/challenge-091/mimosinnet/raku/ch-1.raku b/challenge-091/mimosinnet/raku/ch-1.raku
new file mode 100644
index 0000000000..540a48d763
--- /dev/null
+++ b/challenge-091/mimosinnet/raku/ch-1.raku
@@ -0,0 +1,17 @@
+#!/usr/bin/env raku
+
+for <1122234 2333445 12345> -> $N {
+ my @numbers = $N.split('', :skip-empty);
+ my $initial = @numbers.shift;
+ my ( $enum , $count ) = ( '', 1 );
+ for @numbers {
+ when $initial { $count++ }
+ default {
+ $enum ~= $count.Str ~ $initial;
+ ( $count , $initial ) = ( 1, $_);
+ }
+ }
+ $enum ~= $count.Str ~ $initial.Str;
+ say 'Input: $N = ' ~ $N;
+ say "Output: $enum \n";
+}
diff --git a/challenge-091/mimosinnet/raku/ch-2.raku b/challenge-091/mimosinnet/raku/ch-2.raku
new file mode 100644
index 0000000000..27725287a5
--- /dev/null
+++ b/challenge-091/mimosinnet/raku/ch-2.raku
@@ -0,0 +1,29 @@
+#!/usr/bin/env raku
+
+my @n1 = 1,2,1,2;
+my @n2 = 2,1,1,0,2;
+my @n3 = 2,2,1,2,0,5,2;
+
+for ( @n1, @n2, @n3 ) -> @N {
+ my $output = 0;
+ my $result = 'It does not reach';
+ say 'Input : @N = ' ~ @N;
+ my $initial = @N.shift;
+ while @N {
+ $result = 'It does not reach';
+ if $initial eq @N.elems {
+ $output = 1;
+ $result = 'It jumps to the last index';
+ last;
+ }
+ if $initial gt @N.elems {
+ $output = 1;
+ $result = 'It jumps over the last index';
+ last
+ }
+ my @elems = @N.splice(0,$initial);
+ $initial = pop @elems;
+ last if $initial eq 0;
+ }
+ say "Output: $output ($result) \n";
+}