Skip to main content
6 of 8
added 815 characters in body
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5, 164 bytes

$"=$,;@a=map[/./g],<>;while(@a){say' 'x(length$s)."@{$a[$_]}"for 0..@a-2;say$s.="@{pop@a}";@b=();for$i(0..$#a){$b[$_][$#a-$i]=$a[$i][$_]for 0..$#{$a[$i]}}say;@a=@b}

Try it online!

How?

$"=$,; #set the array output separator to null
@a=map[/./g],<>;   # take the input as a 2-D array @a
while(@a){         # repeat while there are still things to unfurl
  say' 'x(length$s)."@{$a[$_]}"for 0..@a-2; # output all but last
                                            # line of the remaining
                                            # square
  say$s.="@{pop@a}";  # remove bottom row, add it to the unfurled string $s
                      # and output it
  @b=();              # clear temporary array
                      # rotate remaining shape 90 degrees
  for$i(0..$#a){$b[$_][$#a-$i]=$a[$i][$_]for 0..$#{$a[$i]}}
  say;                # output newline
  @a=@b               # replace input with rotated array
}
Xcali
  • 16.2k
  • 2
  • 15
  • 39