DMOPC '14 Contest 5 P1 - New Key

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 50 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 Input

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


  • 0
    pro  commented on Oct. 18, 2017, 5:22 p.m.

    The first Test Case Does Not have an input?


  • -3
    rowanreader  commented on Feb. 10, 2015, 4:38 p.m.

    Is there no Z? And isn't 1(encrypted)=A(decrypted)? How do you get 9?


    • -3
      Sentient  commented on Feb. 10, 2015, 4:52 p.m.

      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).


  • -3
    Oppenheimer  commented on Feb. 10, 2015, 4:28 p.m.

    We know that if we have 4, it will be read as D. So if we have 0, it will be read as 9???


    • -3
      Oppenheimer  commented on Feb. 10, 2015, 4:29 p.m.

      Never mind, just found out by submitting :)


      • -2
        Sentient  commented on Feb. 10, 2015, 4:32 p.m.

        Yes - it was mentioned in the problem statement. Sorry for the confusion.


  • 0
    msa789  commented on Feb. 10, 2015, 4:16 p.m.

    Would it become z or j?


    • 0
      Sentient  commented on Feb. 10, 2015, 4:19 p.m.

      "Important: when decrypting, the input 0 (encrypted) becomes 9 (decrypted). It was shifted one to the left from A."

      So 0 becomes 9.


    • 2
      FatalEagle  commented on Feb. 10, 2015, 4:17 p.m.

      The input 0 decrypts to the output 9.


      • 0
        bobhob314  commented on Feb. 10, 2015, 4:19 p.m.

        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.


  • -2
    sigkill  commented on Feb. 10, 2015, 3:51 p.m.

    If I'm reading the clarification correctly, A is mapped to 0, and then 0 is incremented for a final encryption of '1'.


    • 0
      FatalEagle  commented on Feb. 10, 2015, 3:59 p.m.

      In the model solution, the correct decryption for A is J and for 0 is 9. Sorry for the inconvenience.


    • -2
      Sentient  commented on Feb. 10, 2015, 3:58 p.m.

      No, 0 (encrypted) becomes A (decrypted). This is then shifted to the left to 9.