#12. Moving Values # Given any array x, say [2, 6, 11, 8, -2], create an algorithm that moves each number by one to the front. # For example, when the program is done, an x of [2, 6, 11, 8, -2] should become [6, 11, 8, -2, 2]. x = [2, 6, 11, 8, -2] first = x[0] x.each_with_index {|num, index| if index != x.length-1 x[index] = x[index + 1] else x[index] = first end } print x