Company: Bank of Australia
Difficulty: medium
String Rearrangement Pattern Problem Description You are given a string str1 made of uppercase English letters. Its characters have to be rearranged according to a fixed pattern, and you must print the rearranged string. Write the 26 letters A B C ... Z around a wheel, so that Z is followed by A again and A is preceded by Z . Number the characters of str1 from 1 (the leftmost) to n (the rightmost). Then every character is replaced, in place, as follows: A character at an odd position ( 1 , 3 , 5 , ...) is replaced by the letter one place before it on the wheel. So B becomes A , M becomes L , and A becomes Z . A character at an even position ( 2 , 4 , 6 , ...) is replaced by the letter two places after it on the wheel. So A becomes C , M becomes O , Y becomes A , and Z becomes B . (inferred -- the source does not state the pattern; it only lists the worked examples below and asks you to discover the rule from them. The rule is written out here so that every input has exactly one correct