Skip to content

Instantly share code, notes, and snippets.

@kthallam
Created September 4, 2018 18:09
Show Gist options
  • Save kthallam/7d85aa5a5872245f6747cda0cd9f5d1a to your computer and use it in GitHub Desktop.
Save kthallam/7d85aa5a5872245f6747cda0cd9f5d1a to your computer and use it in GitHub Desktop.
Rotation of an array in ruby
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