Jesse's Problem

5

2 votes
Easy
Problem

Jesse is the most carefree person to ever exist in Albuquerque. He is on a roll making loads of money with his crystal blue meth business alongside the masterming of the trade, Heisenberg.

enter image description here

They usually solve many problems related to science while synthesizing "Methamphetamine". Last time, during their experiment they solved a problem related to series & HCF in Breaking Code 1.0

This time, Heisenberg tried to make him solve another problem by giving him a string S of length N

He told Jesse that each character in the string has an index i, starting from Zero (0-indexed). So, the first character has an index of 0, second has index of 1, and so on. Also there is a shift value for each character, which is obtained by shifting the character (i+1) positions further in the alphabet. If exceeded, the method goes circular, e.g. shifting 'Z' by one position will get an 'A'

"Yo! Mr. White! What the hell are you talkin' about?"

"Just pay attention to the task, Jesse!"

The task is, replace each character Si in the string by its shift value, and then after, switch the case (Uppercase to lowercase & vice versa) of the shift value.

"I don't understand any damn thing, Mr white!"

"See the example below in sample explanation, you'll get everything"

INPUT

  • First line contains an integer T, the number of Test Cases.
  • Each test case consists of a single line, consisting of string S.

OUTPUT

  • Output the answer of each test case in a separate line.

CONSTRAINTS

  • 1 ≤ T ≤ 106
  • 1 ≤ N ≤ 106
  • 1 ≤ T*N ≤ 106
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the 2nd test case, we have the string "zopA" the indices are -

z - 0
o - 1
p - 2
A - 3

Now the shift values can be obtained by shifting the character (i+1) positions into alphabet. We need to shift 'z' 1 time, 'o' 2 times, 'p' 3 times, and 'A' 4 times The shift values for each character are -

z - shifting 1 time - a
o - shifting 2 time - q
p - shifting 3 time - s
A - shifting 4 time - E

so the shift values are 'aqsE'
But for the final answer, we need to switch case
After switching the case, the answer would be 'AQSe'

Editor Image

?