Perl 5, 41 bytes
39 bytes plus two for the
-lF flags (
-M5.01 is free):
perl -lF -M5.01 script.pl
-lFreads the input, removes the trailing newline, puts the remainder into the string
$_, splits it up into characters, and puts that split into the array
/#+/finds the first string of
$`equal to the stuff before it and
$'equal to the stuff after it. If
$`is empty then
$'may contain more
$'.$`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
1to the number of times to rotate the array.
- For each element in that list, we rotate the array (
popthe last element and
unshiftit onto the beginning).
sayall the elements of the rotated array.