Skip to content

Instantly share code, notes, and snippets.

@mikalai-yankouski
Last active November 27, 2018 13:12
Show Gist options
  • Save mikalai-yankouski/97ba5fc5c1414209e91dc17b7f1f8324 to your computer and use it in GitHub Desktop.
Save mikalai-yankouski/97ba5fc5c1414209e91dc17b7f1f8324 to your computer and use it in GitHub Desktop.
Дан целочисленный массив. Осуществить циклический сдвиг элементов массива влево на одну позицию
def random_numbers(n, range)
Array.new(n) { rand(range) }
end
random_array = random_numbers(10, 1..100)
cyclic_shift = random_array.rotate
puts "Array: #{random_array.inspect}"
puts "New Array: #{cyclic_shift}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment