So the goal is to rotate the elements in an array right a times. As an example; if a==2, then array = {0,1,2,3,4} would become
a
a==2
array = {0,1,2,3,4}
In ruby rotating an array can be possible in one line.
def array_rotate(arr) i, j = arr.length - 1, 0 arr[j],arr[i], i, j = arr[i], arr[j], i - 1, j + 1 while(j