#K85397. Taco String Encryption
Taco String Encryption
Taco String Encryption
You are given a string s
consisting of lowercase letters ('a'-'z') and an integer k
. For each character in s
, you need to shift it forward by k
positions in the alphabet. The alphabet wraps around at z
so that, for example, shifting z
by 1 gives a
. In mathematical terms, if you consider the position of a letter c
as an integer from 0 to 25, then the new letter is calculated as
$$ new\_index = (index(c) + k)\mod 26 $$
Your task is to output the encrypted string after applying the shift to every character.
inputFormat
The input consists of two lines:
- The first line contains a string
s
consisting only of lowercase English alphabets. - The second line contains an integer
k
which represents the number of positions to shift each character.
outputFormat
Output the encrypted string after shifting every character of s
by k
positions. The transformation wraps around such that after z
it restarts at a
.
abc
2
cde