aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-073/ash/blog.txt1
-rw-r--r--challenge-073/ash/raku/ch-1.raku27
-rw-r--r--challenge-073/ash/raku/ch-2.raku36
-rw-r--r--challenge-073/ash/raku/ch-2a.raku22
4 files changed, 86 insertions, 0 deletions
diff --git a/challenge-073/ash/blog.txt b/challenge-073/ash/blog.txt
new file mode 100644
index 0000000000..ccfd0b40e1
--- /dev/null
+++ b/challenge-073/ash/blog.txt
@@ -0,0 +1 @@
+https://andrewshitov.com/2020/08/10/raku-challenge-week-73/
diff --git a/challenge-073/ash/raku/ch-1.raku b/challenge-073/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..3546136c65
--- /dev/null
+++ b/challenge-073/ash/raku/ch-1.raku
@@ -0,0 +1,27 @@
+#!/usr/bin/env raku
+
+# Task 1 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-073/
+
+# Comments: https://andrewshitov.com/2020/08/10/raku-challenge-week-73/
+
+my @a = 1, 5, 0, 2, 9, 3, 7, 6, 4, 8;
+my $s = 3;
+
+.min.say for @a.rotor($s => 1 - $s);
+
+# Output:
+# $ raku ch-1.raku
+# 0
+# 0
+# 0
+# 2
+# 3
+# 3
+# 4
+# 4
+
+
+# say @a.rotor(3 => -2);
+## ((1 5 0) (5 0 2) (0 2 9) (2 9 3) (9 3 7) (3 7 6) (7 6 4) (6 4 8))
+## Seq of Lists
diff --git a/challenge-073/ash/raku/ch-2.raku b/challenge-073/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..811f8c215d
--- /dev/null
+++ b/challenge-073/ash/raku/ch-2.raku
@@ -0,0 +1,36 @@
+#!/usr/bin/env raku
+
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-073/
+
+# Comments: https://andrewshitov.com/2020/08/10/raku-challenge-week-73/
+
+my @a = 7, 8, 3, 12, 10;
+
+say @a[$_] < min(@a[^$_]) ?? 0 !! min(@a[^$_]) for ^@a;
+
+# Output:
+# $ raku ch-2.raku
+# 0
+# 7
+# 0
+# 3
+# 3
+
+
+# Uncomment to see the process:
+
+# for ^@a {
+# say @a[^$_];
+# my $current = @a[$_];
+# my $min = min(@a[^$_]);
+# say "Min: $min";
+# say "Current $current";
+
+# if $current < $min {
+# say 0;
+# }
+# else {
+# say $min;
+# }
+# }
diff --git a/challenge-073/ash/raku/ch-2a.raku b/challenge-073/ash/raku/ch-2a.raku
new file mode 100644
index 0000000000..c2858f7368
--- /dev/null
+++ b/challenge-073/ash/raku/ch-2a.raku
@@ -0,0 +1,22 @@
+#!/usr/bin/env raku
+
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-073/
+
+# Comments: https://andrewshitov.com/2020/08/10/raku-challenge-week-73/
+
+my @a = 7, 8, 3, 12, 10;
+
+my $min = Inf;
+for @a -> $v {
+ say $v < $min ?? 0 !! $min;
+ $min = $v if $v < $min;
+}
+
+# Output:
+# $ raku ch-2a.raku
+# 0
+# 7
+# 0
+# 3
+# 3