Middle Pattern
Basic Accuracy: 30.5% Submissions: 11414 Points: 1

Given an odd length word your task is to complete the function printPattern that takes a string s as its argument and prints it from the middle of the word such that it follows the following pattern.
 

Input: PROGRAM                            Input: RAT
Output:                                   Output:
            G                                       A
          GR                                      AT  
        GRA                                     ATR
      GRAM
    GRAMP
  GRAMPR
GRAMPRO

The above is proper shaped pattern for the test case, but when
printed in a single line it becomes as shown in the output. 

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing an odd length string s.

Output:
Corresponding to each test case in a new line print the pattern in a  single line where each row of the pattern is separated by a "$" instead of a new line.

Constraints:
1 ≤ T ≤ 20
1<=size of string(s)<=20

Example(To be used only for expected ouput):
Input
2
PROGRAM
RAT

Output

            G$          GR$        GRA$      GRAM$    GRAMP$  GRAMPR$GRAMPRO$
    A$  AT$ATR$

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.