You will be given a String consisting of printable ASCII (without newlines). Your task is to build a nice Stairway for my Castle.
How to build a nice Stairway?
First off, you should get all the rotations of the String. For example, the String
abcd
has the following rotations:abcd, bcda, cdab, dabc
(each character is moved to the end until we reach the last character).We now place each rotation on top of each other:
abcd bcda cdab dabc
We can't really climb on a straight wall, so we must build stairs. That means you should add a number of spaces before each rotation corresponding to its index in the rotation list:
abcd bcda cdab dabc
You also need a Stairway that links to the other side of my castle, so you should build one like below, reversing each rotation and adding some spacing:
abcd dcba bcda adcb cdab badc dabccbad
This is code-golf, hence the shortest code in bytes wins and standard rules for the tag apply.
Test Cases
Input:
abcd
, Output:abcd dcba bcda adcb cdab badc dabccbad
Input:
aaaa
, Output:aaaa aaaa aaaa aaaa aaaa aaaa aaaaaaaa
Input:
Code golf
, Output (Notice the spaces):Code golf flog edoC ode golfC Cflog edo de golfCo oCflog ed e golfCod doCflog e golfCode edoCflog golfCode edoCflog olfCode g g edoCflo lfCode go og edoCfl fCode gollog edoCf
dab
c. ------- \$\endgroup\$