Roll the carpetLay out the CarpetWind me a number snake!Spiral neighbourhoodsWrite the shortest code to match a tail-repeating string where one character falls off the head in each repetitionShortest code to dump a file into workable memoryFour steps to the left: vipers. Four steps to the right: a cliff. Don't die!Is it a lipogram?Turn a string into a windmillString Addition (Adding a Maximum of 9+9+9)The Three 'R's: Reverse, Reorder, RepeatVisit and exit an arrayOptimal Alphabet SteppingLay out the Carpet

Character reincarnated...as a snail

What would happen to a modern skyscraper if it rains micro blackholes?

"You are your self first supporter", a more proper way to say it

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

Why is Minecraft giving an OpenGL error?

How can bays and straits be determined in a procedurally generated map?

How old can references or sources in a thesis be?

How to determine what difficulty is right for the game?

Perform and show arithmetic with LuaLaTeX

What defenses are there against being summoned by the Gate spell?

Theorems that impeded progress

Maximum likelihood parameters deviate from posterior distributions

Can I make popcorn with any corn?

What does it mean to describe someone as a butt steak?

I'm flying to France today and my passport expires in less than 2 months

Did Shadowfax go to Valinor?

What's that red-plus icon near a text?

How to format long polynomial?

What's the point of deactivating Num Lock on login screens?

Do I have a twin with permutated remainders?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

RSA: Danger of using p to create q



Roll the carpet


Lay out the CarpetWind me a number snake!Spiral neighbourhoodsWrite the shortest code to match a tail-repeating string where one character falls off the head in each repetitionShortest code to dump a file into workable memoryFour steps to the left: vipers. Four steps to the right: a cliff. Don't die!Is it a lipogram?Turn a string into a windmillString Addition (Adding a Maximum of 9+9+9)The Three 'R's: Reverse, Reorder, RepeatVisit and exit an arrayOptimal Alphabet SteppingLay out the Carpet













13












$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 width of the new head (here 2) is less or equal than the length of the tail (here 2)

    • then, put it on top of the tail

    • else, the carpet (as it was at the begining of the step) was rolled


New carpet: ra
pc
et


Repeat the procedure as many times as needed.




Two examples showing all steps of the carpet rolling:



carpet

c
arpet

ac
rpet

ra
pc
et


0123456789

0
123456789

10
23456789

21
30
456789

432
501
6789



Some precisions:



  • You don't need to show all intermediate steps, only the rolled carpet (e.g. if you find a non-iterative way to compute the result, it's perfect). Also, you don't need to print any leading whitespace, in the examples above, I only show them to align stuff.

  • Input is a String, a list/array of char

  • Output is printed to stdout or to a file.

  • Input is nice: the length is at least 1 char, and at most a constant sufficiently small so that it doesn't cause problems, but you can't use that constant in your program; the content of the string is only nice characters ([a-zA-Z0-9]), encoding at your preference.

  • This is code-golf, so shortest answer in bytes wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code.

  • Also, add an explanation for your answer if you think it is needed.









share|improve this question











$endgroup$







  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    14 hours ago






  • 2




    $begingroup$
    Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
    $endgroup$
    – Bromind
    14 hours ago







  • 3




    $begingroup$
    Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
    $endgroup$
    – Sok
    13 hours ago











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    11 hours ago






  • 1




    $begingroup$
    I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
    $endgroup$
    – Erik the Outgolfer
    6 hours ago















13












$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 width of the new head (here 2) is less or equal than the length of the tail (here 2)

    • then, put it on top of the tail

    • else, the carpet (as it was at the begining of the step) was rolled


New carpet: ra
pc
et


Repeat the procedure as many times as needed.




Two examples showing all steps of the carpet rolling:



carpet

c
arpet

ac
rpet

ra
pc
et


0123456789

0
123456789

10
23456789

21
30
456789

432
501
6789



Some precisions:



  • You don't need to show all intermediate steps, only the rolled carpet (e.g. if you find a non-iterative way to compute the result, it's perfect). Also, you don't need to print any leading whitespace, in the examples above, I only show them to align stuff.

  • Input is a String, a list/array of char

  • Output is printed to stdout or to a file.

  • Input is nice: the length is at least 1 char, and at most a constant sufficiently small so that it doesn't cause problems, but you can't use that constant in your program; the content of the string is only nice characters ([a-zA-Z0-9]), encoding at your preference.

  • This is code-golf, so shortest answer in bytes wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code.

  • Also, add an explanation for your answer if you think it is needed.









share|improve this question











$endgroup$







  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    14 hours ago






  • 2




    $begingroup$
    Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
    $endgroup$
    – Bromind
    14 hours ago







  • 3




    $begingroup$
    Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
    $endgroup$
    – Sok
    13 hours ago











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    11 hours ago






  • 1




    $begingroup$
    I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
    $endgroup$
    – Erik the Outgolfer
    6 hours ago













13












13








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 width of the new head (here 2) is less or equal than the length of the tail (here 2)

    • then, put it on top of the tail

    • else, the carpet (as it was at the begining of the step) was rolled


New carpet: ra
pc
et


Repeat the procedure as many times as needed.




Two examples showing all steps of the carpet rolling:



carpet

c
arpet

ac
rpet

ra
pc
et


0123456789

0
123456789

10
23456789

21
30
456789

432
501
6789



Some precisions:



  • You don't need to show all intermediate steps, only the rolled carpet (e.g. if you find a non-iterative way to compute the result, it's perfect). Also, you don't need to print any leading whitespace, in the examples above, I only show them to align stuff.

  • Input is a String, a list/array of char

  • Output is printed to stdout or to a file.

  • Input is nice: the length is at least 1 char, and at most a constant sufficiently small so that it doesn't cause problems, but you can't use that constant in your program; the content of the string is only nice characters ([a-zA-Z0-9]), encoding at your preference.

  • This is code-golf, so shortest answer in bytes wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code.

  • Also, add an explanation for your answer if you think it is needed.









share|improve this question











$endgroup$




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 width of the new head (here 2) is less or equal than the length of the tail (here 2)

    • then, put it on top of the tail

    • else, the carpet (as it was at the begining of the step) was rolled


New carpet: ra
pc
et


Repeat the procedure as many times as needed.




Two examples showing all steps of the carpet rolling:



carpet

c
arpet

ac
rpet

ra
pc
et


0123456789

0
123456789

10
23456789

21
30
456789

432
501
6789



Some precisions:



  • You don't need to show all intermediate steps, only the rolled carpet (e.g. if you find a non-iterative way to compute the result, it's perfect). Also, you don't need to print any leading whitespace, in the examples above, I only show them to align stuff.

  • Input is a String, a list/array of char

  • Output is printed to stdout or to a file.

  • Input is nice: the length is at least 1 char, and at most a constant sufficiently small so that it doesn't cause problems, but you can't use that constant in your program; the content of the string is only nice characters ([a-zA-Z0-9]), encoding at your preference.

  • This is code-golf, so shortest answer in bytes wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code.

  • Also, add an explanation for your answer if you think it is needed.






code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago







Bromind

















asked 14 hours ago









BromindBromind

1866




1866







  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    14 hours ago






  • 2




    $begingroup$
    Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
    $endgroup$
    – Bromind
    14 hours ago







  • 3




    $begingroup$
    Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
    $endgroup$
    – Sok
    13 hours ago











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    11 hours ago






  • 1




    $begingroup$
    I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
    $endgroup$
    – Erik the Outgolfer
    6 hours ago












  • 3




    $begingroup$
    Closely related
    $endgroup$
    – Giuseppe
    14 hours ago






  • 2




    $begingroup$
    Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
    $endgroup$
    – Bromind
    14 hours ago







  • 3




    $begingroup$
    Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
    $endgroup$
    – Sok
    13 hours ago











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    11 hours ago






  • 1




    $begingroup$
    I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
    $endgroup$
    – Erik the Outgolfer
    6 hours ago







3




3




$begingroup$
Closely related
$endgroup$
– Giuseppe
14 hours ago




$begingroup$
Closely related
$endgroup$
– Giuseppe
14 hours ago




2




2




$begingroup$
Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
$endgroup$
– Bromind
14 hours ago





$begingroup$
Also this one: codegolf.stackexchange.com/questions/125966/…, but none include the termination check.
$endgroup$
– Bromind
14 hours ago





3




3




$begingroup$
Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
$endgroup$
– Sok
13 hours ago





$begingroup$
Suggested test case: ProgrammingPuzzlesAndCodeGolf - the final tail length greater than 1 tripped me up.
$endgroup$
– Sok
13 hours ago













$begingroup$
Where is the head on the second carpet example, where nothing is rolled up?
$endgroup$
– Embodiment of Ignorance
11 hours ago




$begingroup$
Where is the head on the second carpet example, where nothing is rolled up?
$endgroup$
– Embodiment of Ignorance
11 hours ago




1




1




$begingroup$
I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
$endgroup$
– Erik the Outgolfer
6 hours ago




$begingroup$
I think you've swapped the words "head" and "tail" here: "if the width of the new head [...] is greater or equal than the length of the tail [...]".
$endgroup$
– Erik the Outgolfer
6 hours ago










4 Answers
4






active

oldest

votes


















2












$begingroup$

Pyth, 37 bytes



.U+j;bZ.WgleHJlhH,+_MChZ<eZJ>eZJ,]hQt


Try it online here, or verify all the test cases at once here.



.U+j;bZ.WgleHJlhH,+_MChZ<eZJ>eZJ,]hQtQ Implicit: Q=eval(input())
Trailing Q inferred
]hQ First character of Q, wrapped in an array
tQ All but the first character of Q
, 2-element array of the two previous results
This yields array with rolled carpet (as array of strings) followed by the tail
.W While condition function is truthy, execute inner function, with initial value of the above:
gleHJlhH Condition function, input H
JlhH Number of layers in the current rolled carpet, store in J
leH Lenth of the tail
g J Is the above greater than or equal to J?
,+_MChZ<eZJ>eZJ Inner function, input Z
_MChZ Rotate the current rolled carpet (transpose, then reverse each row)
+ <eZJ Append the first J characters of the tail as a new row
, Pair the above with...
>eZJ ... all but the first J characters of the tail - this is the new tail
.U+j;bZ Join the carpet roll on newlines and append the tail, implicit print





share|improve this answer











$endgroup$




















    2












    $begingroup$


    J, 73 bytes



    [:(}:@[, 










    2












    $begingroup$


    J, 73 bytes



    [:(:@[,:@:@[,:@:@[,:@[,])&>/[:((:@[,{:@[,])&>/[:((|:@|.@[,#@[.]);#@[.])&>/^:(<:&#&>/)^:_,:@,:@.;.


    Try it online!



    I plan to golf this further after work tonight.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 9 hours ago









    JonahJonah

    2,5611017




    2,5611017





















        1












        $begingroup$


        R, 146 132 bytes





        function(s)m=F[F]
        while(m=rbind(t(m)[,F:0],s[1:F])
        s=s[-1:-F]
        length(s)>sum(F<-dim(m)))0
        write(m[F:1,],1,F[1],,"")
        cat(s,sep="")


        Try it online!



        Implements the carpet-rolling procedure. Takes input as a list of characters and prints to stdout.



        Saved 14 bytes by finding a way to use a do-while loop and initializing using F.



        function(s)
        m=F[F] # logical(0); create an empty array (this gets automatically promoted to character(0) later
        while( # do-while loop
        m=rbind(t(m)[,F:0],s[1:F]) # rotate m counterclockwise and add the first F characters of s to the bottom
        s=s[-1:-F] # remove those characters
        length(s)>sum(F<-dim(m)))0 # while the number of characters remaining is greater than the sum of m's dimensions
        write(m[F:1,],1,F[1],,"") # write the rolled portion write writes down the columns, we reverse each column
        cat(s,sep="") # and write the remaining characters






        share|improve this answer











        $endgroup$

















          1












          $begingroup$


          R, 146 132 bytes





          function(s)m=F[F]
          while(m=rbind(t(m)[,F:0],s[1:F])
          s=s[-1:-F]
          length(s)>sum(F<-dim(m)))0
          write(m[F:1,],1,F[1],,"")
          cat(s,sep="")


          Try it online!



          Implements the carpet-rolling procedure. Takes input as a list of characters and prints to stdout.



          Saved 14 bytes by finding a way to use a do-while loop and initializing using F.



          function(s)
          m=F[F] # logical(0); create an empty array (this gets automatically promoted to character(0) later
          while( # do-while loop
          m=rbind(t(m)[,F:0],s[1:F]) # rotate m counterclockwise and add the first F characters of s to the bottom
          s=s[-1:-F] # remove those characters
          length(s)>sum(F<-dim(m)))0 # while the number of characters remaining is greater than the sum of m's dimensions
          write(m[F:1,],1,F[1],,"") # write the rolled portion write writes down the columns, we reverse each column
          cat(s,sep="") # and write the remaining characters






          share|improve this answer











          $endgroup$















            1












            1








            1





            $begingroup$


            R, 146 132 bytes





            function(s)m=F[F]
            while(m=rbind(t(m)[,F:0],s[1:F])
            s=s[-1:-F]
            length(s)>sum(F<-dim(m)))0
            write(m[F:1,],1,F[1],,"")
            cat(s,sep="")


            Try it online!



            Implements the carpet-rolling procedure. Takes input as a list of characters and prints to stdout.



            Saved 14 bytes by finding a way to use a do-while loop and initializing using F.



            function(s)
            m=F[F] # logical(0); create an empty array (this gets automatically promoted to character(0) later
            while( # do-while loop
            m=rbind(t(m)[,F:0],s[1:F]) # rotate m counterclockwise and add the first F characters of s to the bottom
            s=s[-1:-F] # remove those characters
            length(s)>sum(F<-dim(m)))0 # while the number of characters remaining is greater than the sum of m's dimensions
            write(m[F:1,],1,F[1],,"") # write the rolled portion write writes down the columns, we reverse each column
            cat(s,sep="") # and write the remaining characters






            share|improve this answer











            $endgroup$




            R, 146 132 bytes





            function(s)m=F[F]
            while(m=rbind(t(m)[,F:0],s[1:F])
            s=s[-1:-F]
            length(s)>sum(F<-dim(m)))0
            write(m[F:1,],1,F[1],,"")
            cat(s,sep="")


            Try it online!



            Implements the carpet-rolling procedure. Takes input as a list of characters and prints to stdout.



            Saved 14 bytes by finding a way to use a do-while loop and initializing using F.



            function(s)
            m=F[F] # logical(0); create an empty array (this gets automatically promoted to character(0) later
            while( # do-while loop
            m=rbind(t(m)[,F:0],s[1:F]) # rotate m counterclockwise and add the first F characters of s to the bottom
            s=s[-1:-F] # remove those characters
            length(s)>sum(F<-dim(m)))0 # while the number of characters remaining is greater than the sum of m's dimensions
            write(m[F:1,],1,F[1],,"") # write the rolled portion write writes down the columns, we reverse each column
            cat(s,sep="") # and write the remaining characters







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 12 hours ago

























            answered 13 hours ago









            GiuseppeGiuseppe

            17.6k31152




            17.6k31152





















                1












                $begingroup$


                Jelly, 30 bytes



                Seems overly long...



                ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ


                Try it online!



                How?



                ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ - Main Link: list of characters
                Ḣ - pop and yield head
                W - wrap in a list
                , - pair with (the remaining list after Ḣ)
                ¿ - while...
                $ - ...condition: last two links as a monad:
                Ẉ - length of each
                Ƒ - is invariant under:
                Ṣ - sort
                / - ...do: reduce by:
                ð ð - the enclosed dyadic chain -- i.e. f(head, tail):
                Z - transpose
                U - reverse each (giving a rotated head)
                ɗ - last three links as a dyad:
                ¥ - last two links as a dyad:
                L - length (i.e. number of rows in current roll)
                @ - with swapped arguments:
                s - split (the tail) into chunks of that length
                © - (copy to register for later)
                Ḣ - pop and yield head (Note register "copy" is altered too)
                W - wrap in a list
                ; - concatenate (the rotated head with the first chunk of the tail)
                ¤ - nilad followed by link(s) as a nilad:
                ® - recall from register (other chunks of tail, or an empty list)
                Ẏ - tighten (the chunks to a flat list)
                , - pair (the concatenate result with the tightened chunks)
                Ɗ - last three links as a monad:
                Ḣ - pop and yield head
                Y - join with newline characters
                ; - concatenate (the remaining tail)
                - when running as a full program implicitly prints





                share|improve this answer









                $endgroup$

















                  1












                  $begingroup$


                  Jelly, 30 bytes



                  Seems overly long...



                  ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ


                  Try it online!



                  How?



                  ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ - Main Link: list of characters
                  Ḣ - pop and yield head
                  W - wrap in a list
                  , - pair with (the remaining list after Ḣ)
                  ¿ - while...
                  $ - ...condition: last two links as a monad:
                  Ẉ - length of each
                  Ƒ - is invariant under:
                  Ṣ - sort
                  / - ...do: reduce by:
                  ð ð - the enclosed dyadic chain -- i.e. f(head, tail):
                  Z - transpose
                  U - reverse each (giving a rotated head)
                  ɗ - last three links as a dyad:
                  ¥ - last two links as a dyad:
                  L - length (i.e. number of rows in current roll)
                  @ - with swapped arguments:
                  s - split (the tail) into chunks of that length
                  © - (copy to register for later)
                  Ḣ - pop and yield head (Note register "copy" is altered too)
                  W - wrap in a list
                  ; - concatenate (the rotated head with the first chunk of the tail)
                  ¤ - nilad followed by link(s) as a nilad:
                  ® - recall from register (other chunks of tail, or an empty list)
                  Ẏ - tighten (the chunks to a flat list)
                  , - pair (the concatenate result with the tightened chunks)
                  Ɗ - last three links as a monad:
                  Ḣ - pop and yield head
                  Y - join with newline characters
                  ; - concatenate (the remaining tail)
                  - when running as a full program implicitly prints





                  share|improve this answer









                  $endgroup$















                    1












                    1








                    1





                    $begingroup$


                    Jelly, 30 bytes



                    Seems overly long...



                    ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ


                    Try it online!



                    How?



                    ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ - Main Link: list of characters
                    Ḣ - pop and yield head
                    W - wrap in a list
                    , - pair with (the remaining list after Ḣ)
                    ¿ - while...
                    $ - ...condition: last two links as a monad:
                    Ẉ - length of each
                    Ƒ - is invariant under:
                    Ṣ - sort
                    / - ...do: reduce by:
                    ð ð - the enclosed dyadic chain -- i.e. f(head, tail):
                    Z - transpose
                    U - reverse each (giving a rotated head)
                    ɗ - last three links as a dyad:
                    ¥ - last two links as a dyad:
                    L - length (i.e. number of rows in current roll)
                    @ - with swapped arguments:
                    s - split (the tail) into chunks of that length
                    © - (copy to register for later)
                    Ḣ - pop and yield head (Note register "copy" is altered too)
                    W - wrap in a list
                    ; - concatenate (the rotated head with the first chunk of the tail)
                    ¤ - nilad followed by link(s) as a nilad:
                    ® - recall from register (other chunks of tail, or an empty list)
                    Ẏ - tighten (the chunks to a flat list)
                    , - pair (the concatenate result with the tightened chunks)
                    Ɗ - last three links as a monad:
                    Ḣ - pop and yield head
                    Y - join with newline characters
                    ; - concatenate (the remaining tail)
                    - when running as a full program implicitly prints





                    share|improve this answer









                    $endgroup$




                    Jelly, 30 bytes



                    Seems overly long...



                    ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ


                    Try it online!



                    How?



                    ḢW,ðZU;Ls@¥©ḢWɗ,®Ẏ¤ð/ẈṢƑ$¿ḢY;Ɗ - Main Link: list of characters
                    Ḣ - pop and yield head
                    W - wrap in a list
                    , - pair with (the remaining list after Ḣ)
                    ¿ - while...
                    $ - ...condition: last two links as a monad:
                    Ẉ - length of each
                    Ƒ - is invariant under:
                    Ṣ - sort
                    / - ...do: reduce by:
                    ð ð - the enclosed dyadic chain -- i.e. f(head, tail):
                    Z - transpose
                    U - reverse each (giving a rotated head)
                    ɗ - last three links as a dyad:
                    ¥ - last two links as a dyad:
                    L - length (i.e. number of rows in current roll)
                    @ - with swapped arguments:
                    s - split (the tail) into chunks of that length
                    © - (copy to register for later)
                    Ḣ - pop and yield head (Note register "copy" is altered too)
                    W - wrap in a list
                    ; - concatenate (the rotated head with the first chunk of the tail)
                    ¤ - nilad followed by link(s) as a nilad:
                    ® - recall from register (other chunks of tail, or an empty list)
                    Ẏ - tighten (the chunks to a flat list)
                    , - pair (the concatenate result with the tightened chunks)
                    Ɗ - last three links as a monad:
                    Ḣ - pop and yield head
                    Y - join with newline characters
                    ; - concatenate (the remaining tail)
                    - when running as a full program implicitly prints






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 8 hours ago









                    Jonathan AllanJonathan Allan

                    53.7k535173




                    53.7k535173



























                        draft saved

                        draft discarded
















































                        If this is an answer to a challenge…



                        • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                        • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                          Explanations of your answer make it more interesting to read and are very much encouraged.


                        • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                        More generally…



                        • …Please make sure to answer the question and provide sufficient detail.


                        • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                        draft saved


                        draft discarded














                        StackExchange.ready(
                        function ()
                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182727%2froll-the-carpet%23new-answer', 'question_page');

                        );

                        Post as a guest















                        Required, but never shown





















































                        Required, but never shown














                        Required, but never shown












                        Required, but never shown







                        Required, but never shown

































                        Required, but never shown














                        Required, but never shown












                        Required, but never shown







                        Required, but never shown







                        Popular posts from this blog

                        Reverse int within the 32-bit signed integer range: [−2^31, 2^31 − 1]Combining two 32-bit integers into one 64-bit integerDetermine if an int is within rangeLossy packing 32 bit integer to 16 bitComputing the square root of a 64-bit integerKeeping integer addition within boundsSafe multiplication of two 64-bit signed integersLeetcode 10: Regular Expression MatchingSigned integer-to-ascii x86_64 assembler macroReverse the digits of an Integer“Add two numbers given in reverse order from a linked list”

                        Category:Fedor von Bock Media in category "Fedor von Bock"Navigation menuUpload mediaISNI: 0000 0000 5511 3417VIAF ID: 24712551GND ID: 119294796Library of Congress authority ID: n96068363BnF ID: 12534305fSUDOC authorities ID: 034604189Open Library ID: OL338253ANKCR AUT ID: jn19990000869National Library of Israel ID: 000514068National Thesaurus for Author Names ID: 341574317ReasonatorScholiaStatistics

                        Kiel Indholdsfortegnelse Historie | Transport og færgeforbindelser | Sejlsport og anden sport | Kultur | Kendte personer fra Kiel | Noter | Litteratur | Eksterne henvisninger | Navigationsmenuwww.kiel.de54°19′31″N 10°8′26″Ø / 54.32528°N 10.14056°Ø / 54.32528; 10.14056Oberbürgermeister Dr. Ulf Kämpferwww.statistik-nord.deDen danske Stats StatistikKiels hjemmesiderrrWorldCat312794080n790547494030481-4