aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark <53903062+andemark@users.noreply.github.com>2023-03-06 10:08:53 +0000
committerMark <53903062+andemark@users.noreply.github.com>2023-03-06 10:08:53 +0000
commit0160b6d96c3d18016cff236d65a796a2cb2061d6 (patch)
tree441e23c389d31e594a674b7728872754a9ab92f3
parentd75c83429332efc88f29eee14f988b199f2fa10c (diff)
downloadperlweeklychallenge-club-0160b6d96c3d18016cff236d65a796a2cb2061d6.tar.gz
perlweeklychallenge-club-0160b6d96c3d18016cff236d65a796a2cb2061d6.tar.bz2
perlweeklychallenge-club-0160b6d96c3d18016cff236d65a796a2cb2061d6.zip
Challenge 207 Solutions (Raku)
-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..3f25b822a7
--- /dev/null
+++ b/challenge-207/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,11 @@
+#!/usr/bin/env raku
+use Test;
+
+is keyboard-word(< Hello Alaska Dad Peace >), < Alaska Dad >;
+is keyboard-word(< OMG Bye >), < >;
+is 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..c7daf9dfd7
--- /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, 0), 0;
+is h-index(0, 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)
+{
+ .sort(-*).pairs.first({ .key >= .value }).key // .elems given @a
+}