CC+ is a cyclical cypher. A cyclical cypher is a method of encrypting messages in which every letter in a message is "rotated" some number of positions. For example, if the letters are rotated position then
c and so on (
In a CC+ encryption (Cyclical Cypher Plus) the number of positions a given letter is rotated is based on an integer key value plus the sum of the letters to the right (where
b , etc.). Messages to be encrypted by CC+ must only contain lowercase letters and space characters. No uppercase, digits, punctuation or other types of characters are allowed. Spaces in the original message are removed in the encrypted version.
Before the letters get rotated, special encoding characters are added to the left of the message string. The first two characters represent the number of words in the message as a base number, using lowercase letters (
b , and so on). For example, if there are words, then these letters are
af, which converts to . If there are words, then the letters are
bc, which converts to , the base equivalent of the decimal number . This is followed by a string of characters, each of which represents the length of one of the words in the message (in the order they appeared).
Here's an example encoding using key :
put the lime in the coconut
agddecdh put the lime in the coconut
The input will contain test cases. Each test case will consist of lines. The first line contains an integer and the second contains an encrypted or unencrypted message. Each message contains between and words, each from to characters in length. Words in unencrypted messages are separated by a single space character. Your program should either encode or decode each message (as appropriate) using key and output the result on a single line.
Note that the sample input below consists of only two test cases, but the data files will contain .
5 put the lime in the coconut 13 ccxupnkiivspyqdtlsshwc
bbvspljgzkqxextiaokcpwpljvtfsy and drink it all up
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org