You are viewing a single comment's thread. Return to all comments →
Smart move to slice, hadn't thought about it. One way to improve your code (because I had the same issue): you need to use the generator expression
' '.join(str(s) for s in (arr[d:] + arr[0:d]))
because you applied the int function to your input. Don't do that and it becomes easier:
int
n,d = map(int, raw_input().strip().split()) arr = raw_input().strip().split() print ' '.join(arr[d:] + arr[0:d])
Also, I wouldn't mind an if n == d, but that's just my point of view here.
if n == d
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
Smart move to slice, hadn't thought about it. One way to improve your code (because I had the same issue): you need to use the generator expression
because you applied the
int
function to your input. Don't do that and it becomes easier:Also, I wouldn't mind an
if n == d
, but that's just my point of view here.