27
3
Given a square string, produce all the output for the string at every stage of unfurling.
The string must unfurl in a clockwise direction one quarter turn at a time.
Examples
Input:
A
Output:
A
Note: I'll also accept the input duplicated for this particular test case only if this helps reduce your byte count.
Input:
DC
AB
Output:
DC
AB
D
ABC
ABCD
Input:
GFE
HID
ABC
Output:
GFE
HID
ABC
HG
IF
ABCDE
IH
ABCDEFG
I
ABCDEFGH
ABCDEFGHI
Input:
JIHG
KPOF
LMNE
ABCD
Output:
JIHG
KPOF
LMNE
ABCD
LKJ
MPI
NOH
ABCDEFG
NML
OPK
ABCDEFGHIJ
ON
PM
ABCDEFGHIJKL
PO
ABCDEFGHIJKLMN
P
ABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOP
Rules
This is code-golf so the shortest code in bytes wins.
- Any reasonable format can be used for I/O assuming it is consistent.
- Spaces must be used to pad the top lines of the output.
- Must be able to handle input of all printable characters (including space:
\x20
-\x7e
):
!"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
- Leading/trailing whitespace is allowed.
- You can assume the string will always be a square.
- All standard loopholes are forbidden.
Inspiration: Write a square program that outputs the number of times it has been “unrolled”.
May we output
["A","A"]
for"A"
, like my program does (instead of["A"]
)? It seems reasonable to me since they're just the starting and the ending positions, and you only try to unfurl it once. – Mr. Xcoder – 2017-08-21T07:53:00.163@Mr.Xcoder I agree, adding code to cater for that specific test case seems like a waste of bytes. I'll accept it for the single byte input and update the question accordingly! – Dom Hastings – 2017-08-21T08:15:59.873
3+1 from me, very interesting challenge. This site needs more of these, since they raise the difficulty level and gets rid of the triviality of most solutions. This goes straight to my favourite challenges list. I am disappointed that this has few answers though, I'd really like too see other clever approaches – Mr. Xcoder – 2017-08-21T11:49:44.530
@Mr.Xcoder I'm glad you like it! I wish I could take credit for coming up with the idea alone, but it's all thanks to @HelkaHomba's challenge!
– Dom Hastings – 2017-08-21T12:49:18.047