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

Is it unprofessional to ask if a job posting on GlassDoor is real?

Can a Cauchy sequence converge for one metric while not converging for another?

How much RAM could one put in a typical 80386 setup?

Convert two switches to a dual stack, and add outlet - possible here?

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

What does the "remote control" for a QF-4 look like?

How to determine what difficulty is right for the game?

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

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Why can't I see bouncing of switch on oscilloscope screen?

Today is the Center

Mortgage Pre-approval / Loan - Apply Alone or with Fiancée?

Codimension of non-flat locus

How to source a part of a file

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Why can't we play rap on piano?

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

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

Can you really stack all of this on an Opportunity Attack?

What doth I be?

Replacing matching entries in one column of a file by another column from a different file

Can I make popcorn with any corn?

Horror movie about a virus at the prom; beginning and end are stylized as a cartoon

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



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
    11 hours ago






  • 2




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







  • 3




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











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    8 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
    2 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
    11 hours ago






  • 2




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







  • 3




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











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    8 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
    2 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 2 hours ago







Bromind

















asked 11 hours ago









BromindBromind

1866




1866







  • 3




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






  • 2




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







  • 3




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











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    8 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
    2 hours ago












  • 3




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






  • 2




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







  • 3




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











  • $begingroup$
    Where is the head on the second carpet example, where nothing is rolled up?
    $endgroup$
    – Embodiment of Ignorance
    8 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
    2 hours ago







3




3




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




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




2




2




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





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





3




3




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





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













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




$begingroup$
Where is the head on the second carpet example, where nothing is rolled up?
$endgroup$
– Embodiment of Ignorance
8 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
2 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
2 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



    [:(}:@[,improve this answer








    edited 9 hours ago

























    answered 10 hours ago









    SokSok

    4,177925




    4,177925










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


      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 6 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 9 hours ago

























              answered 10 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 5 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

                          Францішак Багушэвіч Змест Сям'я | Біяграфія | Творчасць | Мова Багушэвіча | Ацэнкі дзейнасці | Цікавыя факты | Спадчына | Выбраная бібліяграфія | Ушанаванне памяці | У філатэліі | Зноскі | Літаратура | Спасылкі | НавігацыяЛяхоўскі У. Рупіўся дзеля Бога і людзей: Жыццёвы шлях Лявона Вітан-Дубейкаўскага // Вольскі і Памідораў з песняй пра немца Адвакат, паэт, народны заступнік Ашмянскі веснікВ Минске появится площадь Богушевича и улица Сырокомли, Белорусская деловая газета, 19 июля 2001 г.Айцец беларускай нацыянальнай ідэі паўстаў у бронзе Сяргей Аляксандравіч Адашкевіч (1918, Мінск). 80-я гады. Бюст «Францішак Багушэвіч».Яўген Мікалаевіч Ціхановіч. «Партрэт Францішка Багушэвіча»Мікола Мікалаевіч Купава. «Партрэт зачынальніка новай беларускай літаратуры Францішка Багушэвіча»Уладзімір Іванавіч Мелехаў. На помніку «Змагарам за родную мову» Барэльеф «Францішак Багушэвіч»Памяць пра Багушэвіча на Віленшчыне Страчаная сталіца. Беларускія шыльды на вуліцах Вільні«Krynica». Ideologia i przywódcy białoruskiego katolicyzmuФранцішак БагушэвічТворы на knihi.comТворы Францішка Багушэвіча на bellib.byСодаль Уладзімір. Францішак Багушэвіч на Лідчыне;Луцкевіч Антон. Жыцьцё і творчасьць Фр. Багушэвіча ў успамінах ягоных сучасьнікаў // Запісы Беларускага Навуковага таварыства. Вільня, 1938. Сшытак 1. С. 16-34.Большая российская1188761710000 0000 5537 633Xn9209310021619551927869394п

                          Беларусь Змест Назва Гісторыя Геаграфія Сімволіка Дзяржаўны лад Палітычныя партыі Міжнароднае становішча і знешняя палітыка Адміністрацыйны падзел Насельніцтва Эканоміка Культура і грамадства Сацыяльная сфера Узброеныя сілы Заўвагі Літаратура Спасылкі НавігацыяHGЯOiТоп-2011 г. (па версіі ej.by)Топ-2013 г. (па версіі ej.by)Топ-2016 г. (па версіі ej.by)Топ-2017 г. (па версіі ej.by)Нацыянальны статыстычны камітэт Рэспублікі БеларусьШчыльнасць насельніцтва па краінахhttp://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/А. Калечыц, У. Ксяндзоў. Спробы засялення краю неандэртальскім чалавекам.І ў Менску былі мамантыА. Калечыц, У. Ксяндзоў. Старажытны каменны век (палеаліт). Першапачатковае засяленне тэрыторыіГ. Штыхаў. Балты і славяне ў VI—VIII стст.М. Клімаў. Полацкае княства ў IX—XI стст.Г. Штыхаў, В. Ляўко. Палітычная гісторыя Полацкай зямліГ. Штыхаў. Дзяржаўны лад у землях-княствахГ. Штыхаў. Дзяржаўны лад у землях-княствахБеларускія землі ў складзе Вялікага Княства ЛітоўскагаЛюблінская унія 1569 г."The Early Stages of Independence"Zapomniane prawdy25 гадоў таму было аб'яўлена, што Язэп Пілсудскі — беларус (фота)Наша вадаДакументы ЧАЭС: Забруджванне тэрыторыі Беларусі « ЧАЭС Зона адчужэнняСведения о политических партиях, зарегистрированных в Республике Беларусь // Министерство юстиции Республики БеларусьСтатыстычны бюлетэнь „Полаўзроставая структура насельніцтва Рэспублікі Беларусь на 1 студзеня 2012 года і сярэднегадовая колькасць насельніцтва за 2011 год“Индекс человеческого развития Беларуси — не было бы нижеБеларусь занимает первое место в СНГ по индексу развития с учетом гендерного факцёраНацыянальны статыстычны камітэт Рэспублікі БеларусьКанстытуцыя РБ. Артыкул 17Трансфармацыйныя задачы БеларусіВыйсце з крызісу — далейшае рэфармаванне Беларускі рубель — сусветны лідар па дэвальвацыяхПра змену коштаў у кастрычніку 2011 г.Бядней за беларусаў у СНД толькі таджыкіСярэдні заробак у верасні дасягнуў 2,26 мільёна рублёўЭканомікаГаласуем за ТОП-100 беларускай прозыСучасныя беларускія мастакіАрхитектура Беларуси BELARUS.BYА. Каханоўскі. Культура Беларусі ўсярэдзіне XVII—XVIII ст.Анталогія беларускай народнай песні, гуказапісы спеваўБеларускія Музычныя IнструментыБеларускі рок, які мы страцілі. Топ-10 гуртоў«Мясцовы час» — нязгаслая легенда беларускай рок-музыкіСЯРГЕЙ БУДКІН. МЫ НЯ ЗНАЕМ СВАЁЙ МУЗЫКІМ. А. Каладзінскі. НАРОДНЫ ТЭАТРМагнацкія культурныя цэнтрыПублічная дыскусія «Беларуская новая пьеса: без беларускай мовы ці беларуская?»Беларускія драматургі па-ранейшаму лепш ставяцца за мяжой, чым на радзіме«Працэс незалежнага кіно пайшоў, і дзяржаву турбуе яго непадкантрольнасць»Беларускія філосафы ў пошуках прасторыВсе идём в библиотекуАрхіваванаАб Нацыянальнай праграме даследавання і выкарыстання касмічнай прасторы ў мірных мэтах на 2008—2012 гадыУ космас — разам.У суседнім з Барысаўскім раёне пабудуюць Камандна-вымяральны пунктСвяты і абрады беларусаў«Мірныя бульбашы з малой краіны» — 5 непраўдзівых стэрэатыпаў пра БеларусьМ. Раманюк. Беларускае народнае адзеннеУ Беларусі скарачаецца колькасць злачынстваўЛукашэнка незадаволены мінскімі ўладамі Крадзяжы складаюць у Мінску каля 70% злачынстваў Узровень злачыннасці ў Мінскай вобласці — адзін з самых высокіх у краіне Генпракуратура аналізуе стан са злачыннасцю ў Беларусі па каэфіцыенце злачыннасці У Беларусі стабілізавалася крымінагеннае становішча, лічыць генпракурорЗамежнікі сталі здзяйсняць у Беларусі больш злачынстваўМУС Беларусі турбуе рост рэцыдыўнай злачыннасціЯ з ЖЭСа. Дазволіце вас абкрасці! Рэйтынг усіх службаў і падраздзяленняў ГУУС Мінгарвыканкама вырасАб КДБ РБГісторыя Аператыўна-аналітычнага цэнтра РБГісторыя ДКФРТаможняagentura.ruБеларусьBelarus.by — Афіцыйны сайт Рэспублікі БеларусьСайт урада БеларусіRadzima.org — Збор архітэктурных помнікаў, гісторыя Беларусі«Глобус Беларуси»Гербы и флаги БеларусиАсаблівасці каменнага веку на БеларусіА. Калечыц, У. Ксяндзоў. Старажытны каменны век (палеаліт). Першапачатковае засяленне тэрыторыіУ. Ксяндзоў. Сярэдні каменны век (мезаліт). Засяленне краю плямёнамі паляўнічых, рыбакоў і збіральнікаўА. Калечыц, М. Чарняўскі. Плямёны на тэрыторыі Беларусі ў новым каменным веку (неаліце)А. Калечыц, У. Ксяндзоў, М. Чарняўскі. Гаспадарчыя заняткі ў каменным векуЭ. Зайкоўскі. Духоўная культура ў каменным векуАсаблівасці бронзавага веку на БеларусіФарміраванне супольнасцей ранняга перыяду бронзавага векуФотографии БеларусиРоля беларускіх зямель ва ўтварэнні і ўмацаванні ВКЛВ. Фадзеева. З гісторыі развіцця беларускай народнай вышыўкіDMOZGran catalanaБольшая российскаяBritannica (анлайн)Швейцарскі гістарычны15325917611952699xDA123282154079143-90000 0001 2171 2080n9112870100577502ge128882171858027501086026362074122714179пппппп

                          ValueError: Expected n_neighbors <= n_samples, but n_samples = 1, n_neighbors = 6 (SMOTE) The 2019 Stack Overflow Developer Survey Results Are InCan SMOTE be applied over sequence of words (sentences)?ValueError when doing validation with random forestsSMOTE and multi class oversamplingLogic behind SMOTE-NC?ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)SmoteBoost: Should SMOTE be ran individually for each iteration/tree in the boosting?solving multi-class imbalance classification using smote and OSSUsing SMOTE for Synthetic Data generation to improve performance on unbalanced dataproblem of entry format for a simple model in KerasSVM SMOTE fit_resample() function runs forever with no result