Skip to content

Instantly share code, notes, and snippets.

@MrPanch
Created October 8, 2021 17:14
Show Gist options
  • Save MrPanch/04cebde3d8028586cea8823438db99c5 to your computer and use it in GitHub Desktop.
Save MrPanch/04cebde3d8028586cea8823438db99c5 to your computer and use it in GitHub Desktop.
n = int(input())
k = int(input())
direction = input()
a = []
for i in range(n):
a.append(int(input()))
result = [0] * n
k %= n
if direction == "LEFT":
k = n - k
result[k] = a[0]
i = 1
j = k+1
while j != k:
result[j] = a[i]
i += 1
j = (j + 1) % n
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment