Perl 5, 68 bytes
65 bytes plus three for the flags: perl -lpF script.pl
$"='';@a="@F@F"=~/#(\d+)/;{unshift@F,pop@F;++$i!=$1&&redo}$_="@F"
I stole the concat(input,input)
trick from other answers here.
1 of 13 | |||||
Perl 5, 68 bytes65 bytes plus three for the flags:
I stole the |