TopCoder problem "SquareCypher" used in TCO07 Round 1C (Division I Level One)



Problem Statement

    

Square cypher is very simple and easy to decrypt. It encrypts a message s=s0s1...sn-1 in the following way: all characters situated on square positions (0, 1, 4, 9, 16...) are moved to the front of the message. The relative order of the moved characters remains the same. For example, the message "thisisacontest" will be encrypted as "thinissacotest".

You are given a String cryptogram. Decrypt it and return the result.

 

Definition

    
Class:SquareCypher
Method:decrypt
Parameters:String
Returns:String
Method signature:String decrypt(String cryptogram)
(be sure your method is public)
    
 

Constraints

-cryptogram will contain between 1 and 50 characters, inclusive.
-cryptogram will contain only lowercase letters ('a'..'z').
 

Examples

0)
    
"thinissacotest"
Returns: "thisisacontest"
This test is from the statement.
1)
    
"thisisacontest"
Returns: "thisiaconstest"
2)
    
"heoll"
Returns: "hello"
Only the letter 'o' was moved.
3)
    
"test"
Returns: "test"
Obviously, short messages (not longer than 4 characters) are not change after the encryption.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7692

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10743&pm=7692

Writer:

Mike Mirzayanov

Testers:

PabloGilberto , brett1479 , vorthys , Olexiy

Problem categories:

Simulation