Created
September 4, 2018 18:09
-
-
Save kthallam/7d85aa5a5872245f6747cda0cd9f5d1a to your computer and use it in GitHub Desktop.
Rotation of an array in ruby
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 rotatearray | |
puts "How Many time to rotate the array in clock wise" | |
times = gets.chomp.to_i | |
a = [] | |
puts "Enter the size of array" | |
size = gets.chomp.to_i | |
puts "Enter the values into array one by one" | |
for i in 0..size-1 | |
i = gets.chomp.to_i | |
a << i | |
end | |
puts "#{a.rotate!(number)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment