diff options
Diffstat (limited to 'challenge-190')
| -rw-r--r-- | challenge-190/mark-anderson/raku/ch-1.raku | 12 | ||||
| -rw-r--r-- | challenge-190/mark-anderson/raku/ch-2.raku | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-190/mark-anderson/raku/ch-1.raku b/challenge-190/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..16b5ff297a --- /dev/null +++ b/challenge-190/mark-anderson/raku/ch-1.raku @@ -0,0 +1,12 @@ +#!/usr/bin/env raku +use Test; + +ok capital-detection("Perl"); +ok capital-detection("TPF"); +nok capital-detection("PyThon"); +ok capital-detection("raku"); + +sub capital-detection($s) +{ + any($s eq $s.tclc, $s eq $s.lc, $s eq $s.uc) +} diff --git a/challenge-190/mark-anderson/raku/ch-2.raku b/challenge-190/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..be1685915e --- /dev/null +++ b/challenge-190/mark-anderson/raku/ch-2.raku @@ -0,0 +1,24 @@ +#!/usr/bin/env raku +use Test; + +is-deeply decode-counts(11), < AA K >; +is-deeply decode-counts(1115), < AAAE AAO AKE KAE KO >; +is-deeply decode-counts(127), < ABG LG >; + +# Not sure how to deal with zeros but this is what the program does. +is-deeply decode-counts(1002001), < ABA ATA JBA JTA >; + +sub decode-counts($n) +{ + sub composition($_) + { + gather .fmt('%0' ~ $n.chars ~ 'b') ~~ m:g/(.)$0* <?{ take $/.pos - $/.from }>/ + } + + sort map + { + my $c := $n.comb.rotor(composition($_))>>.join>>.Int; + next unless all($c) ~~ 1..26; + [~] $c.map({ chr($_+64) }); + }, ^2**($n.chars-1) +} |
