HackerRank içerisinde bulunan “Caesar Cipher” sorusunun açıklaması ve çözümü. Soruda size verilen string’i sezar şifrelemesi ile, harflerini alfabedeki sıralarını verilen sayı kadar ötelemeniz isteniyor.
► HackerRank – Caesar Cipher: https://www.hackerrank.com/challenges/caesar-cipher-1/problem
► Problem açıklaması:
Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar’s cipher (https://en.wikipedia.org/wiki/Caesar_cipher) shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z would map to z, a, b and c.
Original alphabet: abcdefghijklmnopqrstuvwxyz
Alphabet rotated +3: defghijklmnopqrstuvwxyzabc
Sample Input
11
middle-Outz
2
Sample Output
okffng-Qwvb
Explanation
Original alphabet: abcdefghijklmnopqrstuvwxyz
Alphabet rotated +2: cdefghijklmnopqrstuvwxyzab
m — o
i — k
d — f
d — f
l — n
e — g
– –
O — Q
u — w
t — v
z — b