The Rotating Digits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 | |
123 1 | |
489 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
def cal(number , rotaions): | |
numbersList = collections.deque() | |
for d in str(number): | |
numbersList.append(int(d)) | |
numbersList.rotate(int(rotaions)) | |
return numbersList | |
def main(): | |
k = int(input()) | |
for case in range(k): | |
line = input() | |
num , r = line.split() | |
print(case+1,".",end='') | |
numbersList = cal(num,r) | |
for num in numbersList: | |
print(num,end='') | |
print() | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment