aboutsummaryrefslogtreecommitdiff
path: root/challenge-073
diff options
context:
space:
mode:
authorAndrew Shitov <andy@shitov.ru>2020-08-10 06:54:23 +0200
committerAndrew Shitov <andy@shitov.ru>2020-08-10 06:54:23 +0200
commit4c9e4ab4a22ae6bcf1e7da90ef349323efa11145 (patch)
tree3bac6a3b6a2278ebf9cc5fe44a48ac7d19813d65 /challenge-073
parent82d56a626e16b0a7dceeba973b3c69e14031d7f9 (diff)
downloadperlweeklychallenge-club-4c9e4ab4a22ae6bcf1e7da90ef349323efa11145.tar.gz
perlweeklychallenge-club-4c9e4ab4a22ae6bcf1e7da90ef349323efa11145.tar.bz2
perlweeklychallenge-club-4c9e4ab4a22ae6bcf1e7da90ef349323efa11145.zip
ash 073
Diffstat (limited to 'challenge-073')
-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..dd5a4d9a6b
--- /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.kv -> $i, $v {
+ say $v < $min ?? 0 !! $min;
+ $min = $v if $v < $min;
+}
+
+# Output:
+# $ raku ch-2a.raku
+# 0
+# 7
+# 0
+# 3
+# 3