aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-207/mark-anderson/raku/ch-1.raku11
-rw-r--r--challenge-207/mark-anderson/raku/ch-2.raku17
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-207/mark-anderson/raku/ch-1.raku b/challenge-207/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..667171e7db
--- /dev/null
+++ b/challenge-207/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,11 @@
+#!/usr/bin/env raku
+use Test;
+
+is-deeply keyboard-word(< Hello Alaska Dad Peace >), < Alaska Dad >;
+is-deeply keyboard-word(< OMG Bye >), < >;
+is-deeply keyboard-word(< BBC CNN OAN >), < BBC CNN >;
+
+sub keyboard-word(@a)
+{
+ @a.grep({ .lc.comb.cache (<=) any < qwertyuiop asdfghjkl zxcvbnm >>>.comb })
+}
diff --git a/challenge-207/mark-anderson/raku/ch-2.raku b/challenge-207/mark-anderson/raku/ch-2.raku
new file mode 100644
index 0000000000..e8e5fe332b
--- /dev/null
+++ b/challenge-207/mark-anderson/raku/ch-2.raku
@@ -0,0 +1,17 @@
+#!/usr/bin/env raku
+use Test;
+
+is h-index(10, 8, 5, 4, 3), 4;
+is h-index(25, 8, 5, 3, 3), 3;
+is h-index(25, 8, 3, 3, 3), 3;
+is h-index(3), 1;
+is h-index(3, 2), 2;
+is h-index(0, 0, 0), 0;
+is h-index(0, 0, 0, 1), 1;
+is h-index(1, 1, 1, 1, 1), 1;
+is h-index(9, 9, 9, 9, 9), 5;
+
+sub h-index(*@a)
+{
+ @a.sort(-*).pairs.first({ .key < .value }, :end).key.succ // 0
+}