Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kamal-github/65106059255614854f000ad52bfacc72 to your computer and use it in GitHub Desktop.
Save kamal-github/65106059255614854f000ad52bfacc72 to your computer and use it in GitHub Desktop.
program-for-array-rotation-continued-reversal-algorithm
#ex array
def rev_rotation_by_d(a, d)
d.times do
a << a.shift
end
a
end
def rotation_by_d(a, d)
d.times do
a.unshift(a.pop)
end
a
end
a = [3,4,5,1,2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment