- For the
nth line of code, there must be exactly
2n-1characters of the program on it. This causes a triangular/pyramid shape, with the first line having only one character and the rest increasing by increments of 2.
- Each line must be padded with
.s on the left and right, such that the characters are centered on their lines and all lines are padded to the same length. If
lis defined as the number of lines in the program, each line in the program must have a length of
2 * l - 1
For example, the program on the left is valid, but the program on the right isn't:
Valid | Invalid | ...A... | ABCDE ..BCD.. | FGH .EFGHI. | IJKLMN JKLMNOP | OPQRS
When laid out in the valid structure, the name becomes obvious.
Your task is to take a single line string as input, representing Triangularity code, and output it converted into valid code as described above.
Specifications for I/O:
- The input will only contain characters in the range
0x20 - 0x7e
- The length of the input always will be a square number and thus paddable nicely.
- You must use dots for the output padding, not something else.
input ---- output g ---- g PcSa ---- .P. cSa DfJ0vCq7G ---- ..D.. .fJ0. vCq7G 7xsB8a1Oqw5fhHX0 ---- ...7... ..xsB.. .8a1Oq. w5fhHX0 QNYATbkX2sKZ6IuOmofwhgaef ---- ....Q.... ...NYA... ..TbkX2.. .sKZ6IuO. mofwhgaef ABCDEF"$%& G8"F@ ---- ...A... ..BCD.. .EF"$%. & G8"F@ ab.c ---- .a. b.c
For those who know Triangularity, you'll notice from the last test case that strings don't have to be handled