Note:
1. The ‘SECRET_INFORMATION’ may contain any possible character out of 256 valid ASCII characters.
2. While decoding the ‘SECRET_INFORMATION’ do not use class members / global/static variables.
3. Do not use any inbuilt library method/function for decoding the ‘SECRET_INFORMATION’.
The first line of input contains an integer ‘T’ which denotes the number of test cases or queries to be run. Then the test cases follow.
The first and the only line of each test case contains an input string ‘STR’
For each test case, design an algorithm that returns the encoded and decoded string for each input ‘SECRET_INFORMATION’. The output is “Transmission successful” if decoding the encoded string gives the same string as ‘SECRET_INFORMATION’ else the output is “Transmission failed”.
The output of each test case will be printed in a separate line.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
Constraints:
1 <= ‘T’ <= 100
1 <= |SECRET_INFORMATION| <= 5000
Where ‘T’ denotes the total number of test cases and |SECRET_INFORMATION| represents the length of ‘SECRET_INFORMATION’ Ninja has to transfer to his team.
Time Limit: 1 second
Sample Input 1:
2
I love coding ninja
I am Iron Man 3000
Sample Output 1:
Transmission successful
Transmission successful
Explanation for Sample Output 1:
For sample test case 1:
One way to encode the given ‘SECRET_INFORMATION’ is:
First, we find the ASCII value of each character and then add 3 to it. Then we convert this ASCII value into character and replace this with the actual character of ‘SECRET_INFORMATION’ and append ‘!’ after each word of the ‘SECRET_INFORMATION’.
After encoding the ‘SECRET_INFORMATION’ is: “L!oryh!frglqj!qlqmd”.
For decoding the given encoded string we follow the same procedure and for extracting the actual character. First, we find the ASCII value of each character and subtract 3 from it. Then we convert this ASCII value into character.
For sample test case 2:
Another way to encode the given ‘SECRET_INFORMATION’ is:
First, we traverse the given ‘SECRET_INFORMATION’ and append ‘:’ at each word.
After encoding the ‘SECRET_INFORMATION’ is: "I:am:iron:man:3000".
For decoding the given encoded string we follow the same procedure and for extracting the actual character.
Sample Input 2:
2
We say : yes
You are @awesome no. 1
Sample Output 1:
Transmission successful
Transmission successful
Explanation for Sample Output 1:
For sample test case 1:
We can encode ‘SECRET_INFORMATION’ as “Zh!vd|!=!|hv” and decode it in a similar manner.
For sample test case 2:
We can encode ‘SECRET_INFORMATION’ as“\rx!duh!Cdzhvrph!qr1:4” and decode it in a similar manner.