aboutsummaryrefslogtreecommitdiff
path: root/challenge-050/mark-anderson
diff options
context:
space:
mode:
authorMark Anderson <mark@frontrangerunner.com>2020-03-02 12:39:52 -0700
committerMark Anderson <mark@frontrangerunner.com>2020-03-02 12:39:52 -0700
commit232db85d01ad1654e0b2fa6893f83867ccc5788c (patch)
tree8cfa765c682f56343de4a42cdc86d3fcb759a38f /challenge-050/mark-anderson
parent9b64aedf7cae92ccca617184662e133d651c0dee (diff)
downloadperlweeklychallenge-club-232db85d01ad1654e0b2fa6893f83867ccc5788c.tar.gz
perlweeklychallenge-club-232db85d01ad1654e0b2fa6893f83867ccc5788c.tar.bz2
perlweeklychallenge-club-232db85d01ad1654e0b2fa6893f83867ccc5788c.zip
Challenge 50 Solutions
Diffstat (limited to 'challenge-050/mark-anderson')
-rw-r--r--challenge-050/mark-anderson/raku/ch-1.p624
-rw-r--r--challenge-050/mark-anderson/raku/ch-2.p615
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-050/mark-anderson/raku/ch-1.p6 b/challenge-050/mark-anderson/raku/ch-1.p6
new file mode 100644
index 0000000000..39e7d85161
--- /dev/null
+++ b/challenge-050/mark-anderson/raku/ch-1.p6
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl6
+
+my @array = ([2,7], [3,9], [10,12], [15,19], [18,22]);
+
+my @head;
+my @tail;
+
+loop {
+ my $a1 = shift @array;
+ my $a2 = shift @array;
+
+ @head.push([$a1[0], $a2[1]]);
+
+ last unless @array.elems > 1;
+
+ $a2 = pop @array;
+ $a1 = pop @array;
+
+ @tail.push([$a1[0], $a2[1]]);
+
+ last unless @array.elems > 1;
+}
+
+say (@head, @array, @tail).flat;
diff --git a/challenge-050/mark-anderson/raku/ch-2.p6 b/challenge-050/mark-anderson/raku/ch-2.p6
new file mode 100644
index 0000000000..8c5cab0b1a
--- /dev/null
+++ b/challenge-050/mark-anderson/raku/ch-2.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl6
+
+my @L = [2, 6, 1, 3];
+
+for ^@L {
+ my $n = @L.shift;
+
+ if $n <= @L.elems {
+ if @L.grep(* > $n).elems == $n {
+ say $n;
+ }
+ }
+
+ @L.push($n);
+}