Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

13 added 22 characters in body

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds the first string of #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. If $ is empty then $' may contain more #s. However, $'.$ is a string whose initial substring is the number of times to rotate the array.
• Now we build the list 1..$'.$, which provides numeric context totreats $'.$ as an integer and thus numifies it, which strips any final #s, so the list is from 1 to the number of times to rotate the array.
• For each element in that list, we rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds the first string of #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. If $ is empty then $' may contain more #s. However, $'.$ is a string whose initial substring is the number of times to rotate the array.
• Now we build the list 1..$'.$, which provides numeric context to $'.$ and thus numifies it, so the list is from 1 to the number of times to rotate the array.
• For each element in that list, we rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds the first string of #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. If $ is empty then $' may contain more #s. However, $'.$ is a string whose initial substring is the number of times to rotate the array.
• Now we build the list 1..$'.$, which treats $'.$ as an integer and thus numifies it, which strips any final #s, so the list is from 1 to the number of times to rotate the array.
• For each element in that list, we rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.
12 clarify

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds the first string of #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. If $ is empty then $' may contain more #s. However, $'.$ is thusa string whose initial substring is the number of times to rotate the array.
• Now for every element ofwe build the list from 1..$'.$, which provides numeric context to $'.$ and thus numifies it, so the list is from 1 to the number of times to rotate the array.
• For each element in that list, we rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. $'.$ is thus the number of times to rotate the array.
• Now for every element of the list from 1 to $'.$, rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds the first string of #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. If $ is empty then $' may contain more #s. However, $'.$ is a string whose initial substring is the number of times to rotate the array.
• Now we build the list 1..$'.$, which provides numeric context to $'.$ and thus numifies it, so the list is from 1 to the number of times to rotate the array.
• For each element in that list, we rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.
11 one more byte

# Perl 5, 4241 bytes

4039 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1.."$'$";say@F$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. "$'$"$'.$ is thus the number of times to rotate the array.
• Now for every element of the list from 1 to "$'$"$'.$, we rotate the array (pop the last element and unshift it onto the beginning).
• After the loop exits, weThen say all the elements of the rotated array.

# Perl 5, 42 bytes

40 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1.."$'$";say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. "$'$" is thus the number of times to rotate the array.
• Now for every element of the list from 1 to "$'$", we rotate the array (pop the last element and unshift it onto the beginning).
• After the loop exits, we say all the elements of the rotated array.

# Perl 5, 41 bytes

39 bytes plus two for the -lF flags (-M5.01 is free): perl -lF -M5.01 script.pl

/#+/;map{unshift@F,pop@F}1..$'.$;say@F


Explanation:

• -lF reads the input, removes the trailing newline, puts the remainder into the string $_, splits it up into characters, and puts that split into the array @F. • /#+/ finds #s in $_ and sets $ equal to the stuff before it and $' equal to the stuff after it. $'.$ is thus the number of times to rotate the array.
• Now for every element of the list from 1 to $'.$, rotate the array (pop the last element and unshift it onto the beginning).
• Then say all the elements of the rotated array.
10 oops... $'$not $`$'
9 untested but this should work
8 Until now, it didn't handle the zero-rotations case correctly. :-(
7 deleted 78 characters in body
6 deleted 3 characters in body
5 no longer relevant; deleted 29 characters in body
4 deleted 39 characters in body
3 woohoo
2 added 899 characters in body
1