diff options
| -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(" "); +} |
