Roll the carpet
13
4
$begingroup$
This question is inspired by Kevin Cruijssen's question. Now that the carpet is laid out, we want to roll it. Your task is to write a program that takes a string and returns a spiral made from this string (representing a rolled carpet viewed from the side). The procedure for one step of rolling the carpet is the following. There is an example to illustrate what I mean. Notice that the example starts with a partially rolled carpet for better understanding: ac rpet separate the "head" from the "tail" of the carpet: the head is what has been rolled so far, the tail is what remains to be rolled. Head: ac Tail: rp et Rotate the head 90°, clockwise. Rotated head: ra Tail (unchanged): pc et if the widt...