diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-01-25 19:24:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-25 19:24:06 +0000 |
| commit | 0c995329f1442b9618d4eb249a67518b3e1c0ffb (patch) | |
| tree | 39c687c56d99712a577047ce3916dae4714e68f1 | |
| parent | 896825b9cd73bf167b88865f3313b54dcc200bbf (diff) | |
| parent | 1c7e21c38d6198dcff370c065ea0335d093aad2a (diff) | |
| download | perlweeklychallenge-club-0c995329f1442b9618d4eb249a67518b3e1c0ffb.tar.gz perlweeklychallenge-club-0c995329f1442b9618d4eb249a67518b3e1c0ffb.tar.bz2 perlweeklychallenge-club-0c995329f1442b9618d4eb249a67518b3e1c0ffb.zip | |
Merge pull request #3374 from stuart-little/stuart-little_097_raku
1st commit on 097_raku
| -rwxr-xr-x | challenge-097/stuart-little/raku/ch-1.p6 | 7 | ||||
| -rwxr-xr-x | challenge-097/stuart-little/raku/ch-2.p6 | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-097/stuart-little/raku/ch-1.p6 b/challenge-097/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..d0be59447b --- /dev/null +++ b/challenge-097/stuart-little/raku/ch-1.p6 @@ -0,0 +1,7 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> <quoted string> <number> + +say @*ARGS[0].trans(['A'..'Z'] => ['A'..'Z'].rotate(26-@*ARGS[1].Int)) + diff --git a/challenge-097/stuart-little/raku/ch-2.p6 b/challenge-097/stuart-little/raku/ch-2.p6 new file mode 100755 index 0000000000..06038a1f63 --- /dev/null +++ b/challenge-097/stuart-little/raku/ch-2.p6 @@ -0,0 +1,13 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> <binary string> <integer> + +sub res(@strs) { zip(@strs).map(-> @s {@s.classify({$_}).max(*.value.elems).value.head}) } + +sub toflip(@target,@strs) { @strs.map(-> @s {(@s Z!== @target).grep({$_}).elems}).sum } + +my @strs = @*ARGS[0].comb.rotor(@*ARGS[1].Int); +my @target = res(@strs.List); + +say qq|Flip a total number of {toflip(@target,@strs)} positions to get {@target.join} from\n{@strs.map(*.join).join("\n")}| |
