From 0160b6d96c3d18016cff236d65a796a2cb2061d6 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:08:53 +0000 Subject: Challenge 207 Solutions (Raku) --- challenge-207/mark-anderson/raku/ch-1.raku | 11 +++++++++++ challenge-207/mark-anderson/raku/ch-2.raku | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 challenge-207/mark-anderson/raku/ch-1.raku create mode 100644 challenge-207/mark-anderson/raku/ch-2.raku 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 +} -- cgit From ebebdc959141caca7cec4b4d6c374c6e90a575ca Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:14:00 +0000 Subject: Challenge 207 Solutions (Raku) --- challenge-207/mark-anderson/raku/ch-1.raku | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/challenge-207/mark-anderson/raku/ch-1.raku b/challenge-207/mark-anderson/raku/ch-1.raku index 3f25b822a7..de15caf680 100644 --- a/challenge-207/mark-anderson/raku/ch-1.raku +++ b/challenge-207/mark-anderson/raku/ch-1.raku @@ -1,9 +1,9 @@ #!/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 >; +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) { -- cgit From 299ccd70e466a89c89980e77d01abcd19e0cedd8 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:29:02 +0000 Subject: Challenge 207 Solutions (Raku) --- challenge-207/mark-anderson/raku/ch-1.raku | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/challenge-207/mark-anderson/raku/ch-1.raku b/challenge-207/mark-anderson/raku/ch-1.raku index de15caf680..d226573ccc 100644 --- a/challenge-207/mark-anderson/raku/ch-1.raku +++ b/challenge-207/mark-anderson/raku/ch-1.raku @@ -1,11 +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 >; +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 }) + @a.grep({ .lc.comb.cache (<) any < qwertyuiop asdfghjkl zxcvbnm >>>.comb }) } -- cgit From 2bce548e7e0cb6afa22b65a272bb1a455f3b4022 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 6 Mar 2023 10:33:24 +0000 Subject: Challenge 207 Solutions (Raku) --- challenge-207/mark-anderson/raku/ch-1.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-207/mark-anderson/raku/ch-1.raku b/challenge-207/mark-anderson/raku/ch-1.raku index d226573ccc..667171e7db 100644 --- a/challenge-207/mark-anderson/raku/ch-1.raku +++ b/challenge-207/mark-anderson/raku/ch-1.raku @@ -7,5 +7,5 @@ is-deeply keyboard-word(< BBC CNN OAN >), < BBC CNN >; sub keyboard-word(@a) { - @a.grep({ .lc.comb.cache (<) any < qwertyuiop asdfghjkl zxcvbnm >>>.comb }) + @a.grep({ .lc.comb.cache (<=) any < qwertyuiop asdfghjkl zxcvbnm >>>.comb }) } -- cgit From 2c650738498ddfe07ed59d160025eeb250bc8fc2 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Tue, 7 Mar 2023 12:21:05 +0000 Subject: Challenge 207 Solutions (Raku) --- challenge-207/mark-anderson/raku/ch-2.raku | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/challenge-207/mark-anderson/raku/ch-2.raku b/challenge-207/mark-anderson/raku/ch-2.raku index c7daf9dfd7..e8e5fe332b 100644 --- a/challenge-207/mark-anderson/raku/ch-2.raku +++ b/challenge-207/mark-anderson/raku/ch-2.raku @@ -6,12 +6,12 @@ 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(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) { - .sort(-*).pairs.first({ .key >= .value }).key // .elems given @a + @a.sort(-*).pairs.first({ .key < .value }, :end).key.succ // 0 } -- cgit