A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
8 of 13 Until now, it didn't handle the zero-rotations case correctly. :-(

Perl 5, 51 bytes

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



  • -lF reads the input, removes the trailing newline, splits up the remainder into characters, and puts that split into the array @F.
  • /#+/ finds #s in the input string 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 comes a loop: We increment $i (which starts at 0) and test against "$'$`" (the number of times to rotate); if we haven't reached "$'$`" yet, 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 print all the elements of the rotated array.