Course of Raku / Addendum 🆕 / Working with data / Text and strings / Exercises / Caesar cipher
Solution: Caesar cipher
Here is a possible solution to the task.
Code
my $text = 'HELLO';
$text ~~ tr/A..Z/D..ZA..C/;
say $text;🦋 You can find the source code in the file caesar-cipher.raku.
Output
KHOORComments
The transliteration operator
tr///maps characters from the first set to the second, position by position.A..Zlines up againstD..ZA..C, soAbecomesD,BbecomesE, and the tailX Y Zwraps back toA B C.tr///changes the string in place, so$textitself holds the encrypted word after the match.