#K92257. Alphabetic Shift Transformation
Alphabetic Shift Transformation
Alphabetic Shift Transformation
You are given a string s consisting of lowercase English letters and a positive integer k. Your task is to transform the string by shifting each character by k positions forward in the alphabet, wrapping around if necessary. Specifically, for each character c in the string, compute its new character using the formula:
$$new\_char = ((ord(c) - ord('a') + k) \mod 26) + ord('a')$$
For example, if s = "abcdef" and k = 3, then the resulting string is "defghi".
Note: You need to read input from stdin
and output the result to stdout
.
inputFormat
The input consists of two lines:
- The first line contains a string
s
of lowercase English letters (1 to 50 characters). - The second line contains a positive integer
k
(1 to 100), representing the shift value.
outputFormat
Output a single line containing the transformed string after shifting each character by k
positions.
abcdef
3
defghi