#K50622. Alphabetical Character Shifter
Alphabetical Character Shifter
Alphabetical Character Shifter
You are given a string s composed solely of lowercase English letters and an integer N. Your task is to shift each character in the string by N positions in the alphabet. The shifting is cyclic; that is, after 'z' the sequence wraps around to 'a'. Formally, you can compute the new character using the formula:
( new_pos = (old_pos + N) \mod 26 )
where (old_pos) is the 0-indexed position of the letter (with 'a' = 0, 'b' = 1, ..., 'z' = 25) and the result (new_pos) corresponds to the new letter.
For example, if s = "abc" and N = 3, the output should be "def".
inputFormat
The input is read from standard input (stdin). It consists of two lines:
- The first line contains a string s of lowercase English letters.
- The second line contains an integer N indicating the shift value.
outputFormat
The output is written to standard output (stdout) and is a single line containing the shifted string.## sample
abc
3
def