I would do something like this:
x = "ABCDE" x.length.downto(0) do |i| puts x[i..-1] + x[0...i] end
It concatenates the row from the current index to the end, starting from the current index.
Thus, you do not need to modify the original variable at all.
Alex wayne
source share