Write a Ruby program to create an array with the elements "rotated left" of a given array of ints length 3
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]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer