#K32707. Caesar Cipher Encoding
Caesar Cipher Encoding
Caesar Cipher Encoding
You are given a message consisting of lowercase letters and an integer shift value. Your task is to encode the message using a Caesar cipher. For each character c in the message, you need to compute its shifted counterpart via the formula:
\( \text{encoded}(c) = \left( (c - 'a' + \text{shift}) \mod 26 \right) + 'a' \)
The cipher performs a cyclic shift over the alphabet (i.e. 'z' wraps around to 'a'). Each test case requires you to output the encoded string.
Note: The input message will contain only lowercase alphabets with no spaces.
inputFormat
The input is given via stdin and consists of multiple test cases. The first line contains an integer T (the number of test cases). Each of the next T lines contains an integer and a string separated by spaces, where the integer represents the shift value and the string is the message to be encoded.
For example:
3 3 hello -2 world 27 abc
outputFormat
For each test case, output the encoded message on a new line. The output must be printed to stdout.
For the above sample, the output should be:
khoor umpjb bcd## sample
3
3 hello
-2 world
27 abc
khoor
umpjb
bcd
</p>