Hide

Problem B
All Hail Apaxia! Err, Paxaai!

Earlier this summer, researchers at the Oriental Institute came upon a treasure trove of ancient Apaxian scrolls buried under the pitcher’s mound in Wrigley Field. These scrolls have challenged everything we made up thought we knew about Apaxian society.

As it turns out, Apaxians changed their names when they turned 18! The linguists and archaeologists of the Oriental Institute are concerned they’ve misidentified scores of Apaxians in the ancient scrolls, since what they thought were two persons might actually be the same person (with their pre-18 and post-18 names). Fortunately, the names did not change arbitrarily, and would follow two very specific rules:

  1. If the name has an even number of letter, each pair of letters in the name is flipped. More specifically, consider a name as being a string $a_1a_2a_3a_4\ldots a_{n-1}a_ n$ (where each $a_ i$ is a letter, and $n$ is an even number). $a_1a_2$ is the first pair of letters, $a_3a_4$ is the second pair of letters, and so on. In the transformed string, the order of the letters inside each pair is reversed. So, the transformed name would be $a_2a_1a_4a_3\ldots a_ na_{n-1}$

    For example, the name apax would become paxa

  2. If the name had an odd number of letters, the last letter of the name remains the same, and the rest of the name is treated according to rule 1 (unless the name had a single letter; in that case, the name remains unchanged).

    For example, the name alexi would become laxei

As usual, the Oriental Institute has turned to the Department of Computer Science to figure out the equivalence between names.

Input

The input contains a single name. Each name contains only lowercase letters, no whitespace, and has a maximum length of 50 characters.

Output

The output contains the transformed name (according to rules 1 and 2 above).

Sample Input 1 Sample Output 1
apax
paxa
Sample Input 2 Sample Output 2
alexi
laxei
Sample Input 3 Sample Output 3
apalaxios
palaxaois

Please log in to submit a solution to this problem

Log in