aboutsummaryrefslogtreecommitdiff
path: root/challenge-078
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-09-14 10:14:37 +0100
committerGitHub <noreply@github.com>2020-09-14 10:14:37 +0100
commitdd3a7c5ba37a164093d730ec3d1224a0772f8e1f (patch)
tree3111917d8cdfd3e4f9857aac1a1076a3cb46f548 /challenge-078
parent38b6508053972ac52bceac7ebb370039bb1d98f8 (diff)
parentf499375b61cd0dd5f90e73df9a9b69a7384c4c6c (diff)
downloadperlweeklychallenge-club-dd3a7c5ba37a164093d730ec3d1224a0772f8e1f.tar.gz
perlweeklychallenge-club-dd3a7c5ba37a164093d730ec3d1224a0772f8e1f.tar.bz2
perlweeklychallenge-club-dd3a7c5ba37a164093d730ec3d1224a0772f8e1f.zip
Merge pull request #2285 from Scimon/master
Largest integer thing
Diffstat (limited to 'challenge-078')
-rw-r--r--challenge-078/simon-proctor/raku/ch-1.raku10
-rw-r--r--challenge-078/simon-proctor/raku/ch-2.raku16
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-078/simon-proctor/raku/ch-1.raku b/challenge-078/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..82dc9168fe
--- /dev/null
+++ b/challenge-078/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,10 @@
+#!/usr/bin/env raku
+
+use v6;
+
+# Given a list of number print all those larger than all the others left in the list
+sub MAIN(
+ *@a where { .all ~~ Int } #= List of integers
+) {
+ @a.kv.map( -> $i, $v { $v >= all(@a[$i..*]) ?? $v !! Empty }).join(", ").say;
+}
diff --git a/challenge-078/simon-proctor/raku/ch-2.raku b/challenge-078/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..2829c53442
--- /dev/null
+++ b/challenge-078/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+
+use v6
+my %*SUB-MAIN-OPTS = :named-anywhere;
+#| Given a list of values and some named pivot points rotate the list
+#| so that the given pivot is first in the list
+sub MAIN (
+ *@values where { $_.elems > 0 }, #= List to rotate
+ # There's a weird Emacs Raku mode bug with < hence <= elems-1
+ :p(:@pivots)! where { .all ~~ UInt && .all <= @values.elems-1 }, #= List of values to rotate
+) {
+ for @pivots -> $p {
+ [ |@values[$p..*], |@values[0..^$p] ].say
+ }
+
+}