Given a string, first square it as follows:
First, write the string.
abcde
Next, write the string rotated one left.
abcde
bcdea
Keep doing this until you have written len(string) lines.
abcde
bcdea
cdeab
deabc
eabcd
Now, read from the string like this:
----+
+--+|
|+>||
|+-+|
+---+
Which gives:
abcdeabcdcbaedcbcdeabaede
Print this string.
Test cases
abcdef -> abcdefabcdedcbafedcbcdefabcbafedefaf
cena! -> cena!cenanec!anena!cec!a!
ppcg -> ppcgppcppgcpcgpg
abc -> abcabacbc
ab -> abab
a -> a
->
Please comment if a test case is incorrect.
Remember, this is code-golf, so the code with the smallest number of bytes wins.
cena!
is wrong. It should match your example withabcde
since both are 5 letters:cena!cenanec!anena!cec!a!
\$\endgroup\$