Q:

Write a Ruby program to create an array with the elements "rotated left" of a given array of ints length 3

0

 Write a Ruby program to create an array with the elements "rotated left" of a given array of ints length 3

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_array(nums)
    rotated = nums[1], nums[2], nums[0];
	return rotated;
end
print check_array([1, 2, 5]),"\n" 
print check_array([1, 2, 3]),"\n" 
print check_array([1, 2, 4]) 

Output:

[2, 5, 1]
[2, 3, 1]
[2, 4, 1]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now