Skip to content

Instantly share code, notes, and snippets.

@MrSimsek
Last active July 23, 2017 07:23
Show Gist options
  • Save MrSimsek/cac5d69d2a707558daf3b9eddeed6ebf to your computer and use it in GitHub Desktop.
Save MrSimsek/cac5d69d2a707558daf3b9eddeed6ebf to your computer and use it in GitHub Desktop.
Arrays: Left Rotation
def array_left_rotation(a, n, k):
# Creta Empty List
b = []
# Loop through a
for i in range(n):
# Append new position value to b
b.append(a[(i + k) % n])
return b
n, k = 5, 4 # map(int, input().strip().split(' '))
a = [1, 2, 3, 4, 5] # list(map(int, input().strip().split(' ')))
answer = array_left_rotation(a, n, k);
print(*answer, sep=' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment