2 of 13 added 899 characters in body

Perl 5, 67 bytes

64 bytes plus three for the flags: perl -lpF script.pl


I stole the concatenate(input,input) trick from other answers here.


  • -lpF reads the input, removes the trailing newline, splits up the remainder into characters, and puts that split into the array @F.
  • $"='' makes sure that when we stringify an array it has no spaces in it.
  • "@F@F"=~/#(\d+)/, in the list context supplied by (...), is the match of all the digits immediately following a # in the stringified @F (which is the input string) concatenated with itself. This will be the number of times we want to rotate the array. It's assigned to $1.
  • Now comes a loop: We increment $i (which starts at 0) and test against $1 (the number of times to rotate); if we haven't reached $1yet, we redo the loop. What does the loop do? Simple: it rotates the array (pops the last element and unshifts it onto the beginning).
  • After the loop exits, we assign the stringified shifted loop to $_ so that -p prints it.