


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.
You do not need to print anything; it has already been taken care of. Just implement the given function.
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
For encoding the given ‘SECRET_INFORMATION’ we can use any algorithm. Here first, we append the number of words of ‘SECRET_INFORMATION’ and ‘!’ into our resultant decoding string ‘ENCODED_INFORMATION’. Then we append the length of each word and ‘!’. At last, we find the ‘ASCII’ value of each character and then add 3 into the ASCII value. Then we convert this ASCII value into a character and replace this with the actual character of ‘SECRET_INFORMATION’ and append ‘!’ after each word of the ‘SECRET_INFORMATION’ into the ‘ENCODED_INFORMATION’.
For decoding the ‘ENCODED_INFORMATION’ we follow the exact same steps in the same order which we followed for finding the ‘ENCODED_INFORMATION’. Only one difference is for extracting the actual character of the ‘SECRET_INFORMATION’. First, we find the ASCII value of each character and subtract 3 into the ASCII value. Then we convert this ASCII value into character.
Here is the algorithm: