Problem title
Difficulty
Avg time to solve

Maximum Score From Removing Stones
Easy
15 mins
Boxes of Power
Easy
20 mins
NINJAS TRUCK
Easy
15 mins
Campus Cycles
Easy
15 mins
Sell Diminishing Bricks
Moderate
25 mins
Permutation Before One Swap
Moderate
25 mins
String Without 000 Or 111
Easy
15 mins
Power Of 2
Moderate
20 mins
Ninja And Rearrange String
Moderate
30 mins
Rabbits In Forest
Easy
15 mins
2

Ninja And His Secret Information

Difficulty: MEDIUM
Contributed By
Avg. time to solve
30 min
Success Rate
70%

Problem Statement

Ninja has recently joined the FBI. Ninja got some secret information ‘SECRET_INFORMATION’ which he wants to share with his team. But he can not send this information directly because of the hackers and security threats they pose.

So Ninja decides to encode this ‘SECRET_INFORMATION’ and then send the encoded ‘SECRET_INFORMATION’ to his team members. This way, only his team members can decode this information and thus share it safely.

As Ninja is busy extracting the ‘SECRET_INFORMATION, he asks you for help.

Can you help Ninja and his friends with encoding and decoding the ‘SECRET_INFORMATION’?

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’.
Input Format:
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’ 
Output Format :
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.
Reset Code
Full screen
copy-code
Console