PRIORITY ONE TRANSMISSION
- Union of Ecraxus
From: Agent Lore, Ecraxian Naval Intelligence, Section 2
Subject: New Key
Rumours are coming in from far sections of space that state the Hoyd aliens have deciphered our current system of coding for secret messages. Though this has not yet been confirmed, we have decided to play it safe and implement a new system.
In this new system, a letter is represented by something other than itself. Numbers 0
–9
represent letters A
–J
(in order), letters A
–J
represent the letters from K
–T
, while the letters K
–P
represent the letters U
–Z
.
To make it more difficult to decipher, in the decryption procedure, each character must then be shifted one to the left for the message to make sense. To decrypt 4
to D
, 4
is changed to E
, and then E
is shifted to D
. Important: when decrypting, the input 0
(encrypted) becomes 9
(decrypted). It was shifted one to the left from A
.
We need you to make a key for this new code so that our agents will be able to communicate with one another.
Input Specification
The only line of input will contain the encrypted message. It will have a length of up to characters and will contain only digits 0
–9
and letters A
–P
, uppercase only.
Output Specification
The only line of input should contain the decrypted message.
Sample Input
4DFG3
Sample Output
DMOPC
Explanation for Sample Output
The first character, 4
(0,1,2,3,4,5,6,7,8,9) becomes E
(A,B,C,D,E,F,G,H,I,J). It is then shifted to the left by one to obtain D
, the decrypted character.
Comments
The alphabet (encrypted) is 0123456789ABC...P
The alphabet (decrypted) has no Z but is instead ABC...XY9 (Somehow it managed to pass the test cases)
locate the index and account for the shift.
Hope that doesn't give too much away.
Is there no Z? And isn't 1(encrypted)=A(decrypted)? How do you get 9?
You're right - 1 (encrypted) => A (decrypted). The problem statement says that 0 (encrypted) becomes 9 (decrypted). Also, you are correct again, there is no Z (not like anyone really uses it).
We know that if we have 4, it will be read as D. So if we have 0, it will be read as 9???
Never mind, just found out by submitting :)
Yes - it was mentioned in the problem statement. Sorry for the confusion.
Would it become z or j?
"Important: when decrypting, the input 0 (encrypted) becomes 9 (decrypted). It was shifted one to the left from A."
So 0 becomes 9.
The input
0
decrypts to the output9
.The entire alphabet (in step two) is shifted to the right such that the leftmost character is 9 and all of the remaining ones to the right of 9 are just ABCD...Y.
If I'm reading the clarification correctly, A is mapped to 0, and then 0 is incremented for a final encryption of '1'.
In the model solution, the correct decryption for
A
isJ
and for0
is9
. Sorry for the inconvenience.No, 0 (encrypted) becomes A (decrypted). This is then shifted to the left to 9.