#C9586. Perform String Shifts
Perform String Shifts
Perform String Shifts
Given a string S consisting of lowercase English letters and an array of integers shift of the same length, your task is to shift each character in S to the right by the corresponding value in shift. The shifting is cyclic, meaning if the shift passes 'z', it wraps around to 'a'.
Mathematically, the new character is computed as follows:
$$ new\_char = \text{chr}((\text{ord}(c) - \text{ord}('a') + shift[i]) \bmod 26 + \text{ord}('a')) $$
For example, if S = "abcdef" and shift = [1, 2, 3, 4, 5, 6], then the result is "bdfhjl".
inputFormat
The input is given through standard input (stdin) and consists of two lines:
- The first line contains the string S (only lowercase English letters).
- The second line contains space-separated integers representing the shift values. The number of integers is equal to the length of S.
outputFormat
Output the resulting string after applying the shifts to each corresponding character of S to standard output (stdout).
## sampleabcdef
1 2 3 4 5 6
bdfhjl