Last active
November 27, 2018 13:12
-
-
Save mikalai-yankouski/97ba5fc5c1414209e91dc17b7f1f8324 to your computer and use it in GitHub Desktop.
Дан целочисленный массив. Осуществить циклический сдвиг элементов массива влево на одну позицию
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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