aboutsummaryrefslogtreecommitdiff
path: root/challenge-078/ash
diff options
context:
space:
mode:
authorAndrew Shitov <andy@shitov.ru>2020-09-14 09:46:34 +0200
committerAndrew Shitov <andy@shitov.ru>2020-09-14 09:46:34 +0200
commit11921311ef55ec79c9fce3edb0de53ca0a468a0e (patch)
treedbcc01fda122aaa259f80e49e492b78f2024f599 /challenge-078/ash
parent735595504f778396eac218963ea81a6b20d75f67 (diff)
downloadperlweeklychallenge-club-11921311ef55ec79c9fce3edb0de53ca0a468a0e.tar.gz
perlweeklychallenge-club-11921311ef55ec79c9fce3edb0de53ca0a468a0e.tar.bz2
perlweeklychallenge-club-11921311ef55ec79c9fce3edb0de53ca0a468a0e.zip
ash 078 (1, 2)
Diffstat (limited to 'challenge-078/ash')
-rw-r--r--challenge-078/ash/blog.txt1
-rw-r--r--challenge-078/ash/raku/ch-1.cpp30
-rw-r--r--challenge-078/ash/raku/ch-1.raku12
-rw-r--r--challenge-078/ash/raku/ch-2.raku11
4 files changed, 54 insertions, 0 deletions
diff --git a/challenge-078/ash/blog.txt b/challenge-078/ash/blog.txt
new file mode 100644
index 0000000000..0bed715d48
--- /dev/null
+++ b/challenge-078/ash/blog.txt
@@ -0,0 +1 @@
+https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
diff --git a/challenge-078/ash/raku/ch-1.cpp b/challenge-078/ash/raku/ch-1.cpp
new file mode 100644
index 0000000000..875dc4a005
--- /dev/null
+++ b/challenge-078/ash/raku/ch-1.cpp
@@ -0,0 +1,30 @@
+/*
+ Task 1 from
+ https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/
+
+ Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
+
+ Compile as:
+ $ g++ -std=c++17 ch-1.cpp
+*/
+
+#include <iostream>
+#include <vector>
+
+using namespace std;
+
+int main() {
+ vector<int> a = {9, 10, 7, 5, 6, 1};
+
+ auto max = a.back();
+ vector<int> leaders = {max};
+ for (auto i = a.rbegin(); i != a.rend(); i++) {
+ if (*i > max) {
+ max = *i;
+ leaders.push_back(max);
+ }
+ }
+
+ for (auto i = leaders.rbegin(); i != leaders.rend(); i++)
+ cout << *i << endl;
+}
diff --git a/challenge-078/ash/raku/ch-1.raku b/challenge-078/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..d7cda4daed
--- /dev/null
+++ b/challenge-078/ash/raku/ch-1.raku
@@ -0,0 +1,12 @@
+#!/usr/bin/env raku
+
+# Task 1 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/
+
+# Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
+
+my @a = 9, 10, 7, 5, 6, 1;
+
+for @a.kv -> $i, $v {
+ say $v if $v > all(@a[$i^..*]);
+}
diff --git a/challenge-078/ash/raku/ch-2.raku b/challenge-078/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..af9f61a1e4
--- /dev/null
+++ b/challenge-078/ash/raku/ch-2.raku
@@ -0,0 +1,11 @@
+#!/usr/bin/env raku
+
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-078/
+
+# Comments: https://andrewshitov.com/2020/09/14/the-weekly-challenge-078/
+
+my @a = 10, 20, 30, 40, 50;
+my @b = 3, 4;
+
+say @a.rotate($_) for @b; \ No newline at end of file