diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-01-25 19:16:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-25 19:16:29 +0000 |
| commit | cfbe8ea62b5842e813b01039223dca2618d3bed4 (patch) | |
| tree | 1eb79ee1775d5f0f2b29c17ef5481dc1446eb3ae | |
| parent | 99f60b6d15edbba7f87a12903e580083fa20adfc (diff) | |
| parent | 6058b52198f35728c85bfcaa463d68312606c5ac (diff) | |
| download | perlweeklychallenge-club-cfbe8ea62b5842e813b01039223dca2618d3bed4.tar.gz perlweeklychallenge-club-cfbe8ea62b5842e813b01039223dca2618d3bed4.tar.bz2 perlweeklychallenge-club-cfbe8ea62b5842e813b01039223dca2618d3bed4.zip | |
Merge pull request #3373 from Scimon/master
Ceaser Cypher
| -rw-r--r-- | challenge-097/simon-proctor/raku/ch-1.raku | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-097/simon-proctor/raku/ch-1.raku b/challenge-097/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..c0436002bc --- /dev/null +++ b/challenge-097/simon-proctor/raku/ch-1.raku @@ -0,0 +1,15 @@ +#!/usr/bin/env raku + +use v6; + +#| Given a shift amount (integer can be negative) and a list of string encode using the Ceaser Cypher +sub MAIN( + Int() $shift is copy, #= Amount to shift the letters by + *@words where @words.grep({ ! m!^ <[A..Z]>+ $! }).elems == 0 #= Words, all uppercase +) { + my @alpha = ("A".."Z").Array; + if ( $shift < 0 ) { $shift = 26+$shift } + my @shifted = [ |@alpha[(26-$shift)..25], |@alpha[0..(25-$shift)] ]; + + say @words.map( { $_.trans( @alpha.join => @shifted.join ) } ).join(" "); +} |
