Skip to content

Instantly share code, notes, and snippets.

@gbazilio
Created January 4, 2017 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbazilio/f01fc335d8ad01e94df6ffd9a98803ab to your computer and use it in GitHub Desktop.
Save gbazilio/f01fc335d8ad01e94df6ffd9a98803ab to your computer and use it in GitHub Desktop.
Codility - Cyclic Rotation
def solution(A, K):
A_length = len(A)
new_A_array = [0] * A_length
for index in range(A_length):
shift_index = (index+K) % A_length
new_A_array[shift_index] = A[index]
return new_A_array
def solutionA(A, K):
K = K % len(A)
new_A_array = A[-K:] + A[:-K]
return new_A_array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment