A rotor cipher machine encodes a message so that the shift increases as it advances. For the character at 0-indexed position i in the message, the machine shifts it forward by (k + i) positions in the lowercase alphabet, wrapping around from z to a. The message contains only lowercase English letters.
Given the base shift k and the plaintext message, print the encoded text.
Line 1: an integer k, the base shift.
Line 2: the plaintext message, a non-empty string of lowercase English letters.
A single line: the encoded message.
a-z).Example 1
Input
0 abc
Expected
ace
Explanation
Shifts are 0,1,2: a->a, b->c, c->e, giving 'ace'.
Example 2
Input
1 aaaa
Expected
bcde
Explanation
Shifts are 1,2,3,4 applied to each a: b,c,d,e, giving 'bcde'.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →