Keyword Shift Cipher
Encode message with a keyword shift. key is a non-empty word of lowercase letters, and each of its letters stands for a shift amount: a is 0, b is 1, and so on up to z, which is 25. Going through the letters of message from left to right, shift the 1st letter by the amount of key[0], the 2nd letter by key[1], and so on, starting again from key[0] after the last letter of key has been used. Shifting moves a letter forward in the alphabet, wrapping from z back to a.
Only letters are shifted and only letters use up a key position: spaces and punctuation are copied unchanged and do not advance the key. Uppercase letters shift within the uppercase alphabet (Z wraps to A). Return the encoded message.
Example 1
The key lemon gives the shifts 11, 4, 12, 14, 13 and then repeats; a + 11 is l, t + 4 is x, t + 12 is f, and so on. The spaces use no key letter.
Example 2
The key a is a shift of 0 for every letter.
Constraints
0 <= len(message) <= 601 <= len(key) <= 10messagehas letters, spaces and the punctuation! ? . , ' -onlykeyhas lowercase letters only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.