aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2020-11-23 01:25:10 -0500
committerchirvasitua <stuart-little@users.noreply.github.com>2020-11-23 01:25:10 -0500
commit29a91f5fe7d45d948f8ba3755091188a98558f6a (patch)
treee4c054f9a9d1567d7afb97ef9fcd5157054bfa14
parentcea83925f87e4bbe52ab8c1ce9a2e1b0f2d86611 (diff)
downloadperlweeklychallenge-club-29a91f5fe7d45d948f8ba3755091188a98558f6a.tar.gz
perlweeklychallenge-club-29a91f5fe7d45d948f8ba3755091188a98558f6a.tar.bz2
perlweeklychallenge-club-29a91f5fe7d45d948f8ba3755091188a98558f6a.zip
1st commit on 088
-rwxr-xr-xchallenge-088/stuart-little/raku/ch-1.p68
-rwxr-xr-xchallenge-088/stuart-little/raku/ch-2.p629
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-088/stuart-little/raku/ch-1.p6 b/challenge-088/stuart-little/raku/ch-1.p6
new file mode 100755
index 0000000000..a9443efa74
--- /dev/null
+++ b/challenge-088/stuart-little/raku/ch-1.p6
@@ -0,0 +1,8 @@
+#!/usr/bin/env perl6
+use v6;
+
+sub skipprod(@a) { @a.keys.map({ @a.keys.grep(* !~~ $_) }).map({ [*] @a[@($_)] }) }
+
+say @*ARGS.map(*.Int).&skipprod
+
+# run as <script> <space-separated array entries>
diff --git a/challenge-088/stuart-little/raku/ch-2.p6 b/challenge-088/stuart-little/raku/ch-2.p6
new file mode 100755
index 0000000000..6157f33570
--- /dev/null
+++ b/challenge-088/stuart-little/raku/ch-2.p6
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl6
+use v6;
+
+sub peel(@a) { |@a[0], |@a[1..*].map(*.[*-1]) }
+sub core(@a) { @a[1..*].map(*.[0..*-2]) }
+
+sub spiral(@a) { min(@a.elems,@a[0].elems) == 1 && return peel(@a); return (|@a.&peel, |@a.&core.map(*.reverse).reverse.&spiral) }
+
+my @a0=[
+ [ 1, 2, 3 ],
+ [ 4, 5, 6 ],
+ [ 7, 8, 9 ],
+];
+
+my @a1=[
+ [ 1, 2, 3, 4 ],
+ [ 5, 6, 7, 8 ],
+ [ 9, 10, 11, 12 ],
+ [ 13, 14, 15, 16 ],
+];
+
+my @a2=[
+ [ 1, 2, 3, 4 ],
+ [ 5, 6, 7, 8 ],
+];
+
+for (@a0,@a1,@a2) {.&spiral.say}
+
+# run as <script>