Roy and Cipher Disk
Practice
4.4 (33 votes)
Ad Hoc
Approved
Data structures
Easy
Implementation
Open
Problem
45% Success 6992 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Roy's friends has been spying on his text messages, so Roy thought of an algorithm to encrypt text messages.

Encryption Algorithm is as follows:
We say message to be encrypted as Plain Text and encrypted form of message as Cipher.
Plain Text consists of lower case alphabets only.
Consider the Cipher Disk as shown in figure.

enter image description here

Initially, we start with 0 (zero). For each character in Plain Text, we move either clockwise or anti-clockwise on the disk depending on which way is closest from where we are currently standing.
If both clockwise and anti-clockwise distances are equal, we give priority to clockwise movement.
Clockwise movements are represented using positive numbers while Anti-clockwise movements are represented as negative numbers.

Roy needs your help in implementing this algorithm. Given a Plain Text message, your task is to encrypt it using above algorithm and print the Cipher Text.

Input:
First line contains integer T - number of test cases.
Each of next T lines contains a string representing Plain Text message.

Output:
For each test case, print the encrypted form of given string in new line.
Each line should consist of space separated integers in the range [-12,13].
See the sample test case for more clarification.

Constraints:
1 <= T <= 100
1 <= Length of Plain Text string <= 100

Sample Test Case Explanation:
Explanation for 3rd sample test case "correct"

enter image description here

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
38 votes
Tags:
ApprovedData StructuresEasyImplementationOpen
Points:20
19 votes
Tags:
ArraysBasic ProgrammingEasyOpen
Points:20
77 votes
Tags:
ApprovedBasic ProgrammingEasyImplementationOpen