TopCoder problem "SuperRot" used in SRM 154 (Division II Level Two)

Problem Statement

    There exists a basic encryption method known as ROT13. One property of ROT13 is that the encryption and decryption processes are exactly the same. These processes work by doing a simple transformation from one letter of the alphabet to another. The letters A through M become N through Z, such that A->N, B->O, ..., M->Z. The letters N through Z become A through M, such that N->A, O->B, ..., Z->M.

One of the problems with most implementations is that everything is converted to upper case. Another problem is that numbers are ignored completely, leaving them unencrypted. One way to overcome these limitations is to extend ROT13 to cover lowercase letters as well as numbers. Here is how our extended ROT transformations will work:
characters   become
   A-M        N-Z
   N-Z        A-M
   a-m        n-z
   n-z        a-m
   0-4        5-9
   5-9        0-4

For example, the message "Uryyb 28" would become "Hello 73" after being transformed.
   U -> H        2 -> 7
   r -> e        8 -> 3
   y -> l
   y -> l
   b -> 0
Notice that the spaces were left as is.

You have intercepted a message which you believe to be encrypted using this process. Create a class SuperRot with a method decoder that takes a String message and returns the decoded message as a String.


Method signature:String decoder(String message)
(be sure your method is public)


-All spaces occuring in message are left as spaces in the decoded String.


-message will have between 0 and 50 characters inclusive.
-message will consist only of letters 'a' - 'z' and 'A' - 'Z', digits '0' - '9', and the space character.
-message will not contain two or more consecutive spaces.
-There will be no leading or trailing spaces.


"Uryyb 28"
Returns: "Hello 73"
This is the example from above.
Returns: "TopCoder"
G -> T
b -> o
c -> p
P -> C
b -> o
q -> d
r -> e
e -> r
Returns: ""
Remember the empty String.
Returns: "0123456789"
"NnOoPpQqRr AaBbCcDdEe"
Returns: "AaBbCcDdEe NnOoPpQqRr"
"Gvzr vf 54 71 CZ ba Whyl 4gu bs gur lrne 7558 NQ"
Returns: "Time is 09 26 PM on July 9th of the year 2003 AD"
"Gur dhvpx oebja sbk whzcf bire n ynml qbt"
Returns: "The quick brown fox jumps over a lazy dog"

Problem url:

Problem stats url:




lbackstrom , brett1479

Problem categories:

Encryption/Compression, String Manipulation