题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
愚蠢的我用愚蠢的办法 il = input().split(";") pos = [0,0] for i in il: if len(i)==2: if i[0]=='A' or i[0]=='S' or i[0]=='W' or i[0]=='D': if ord(i[1])>=48 and ord(i[1])<=57: if i[0]=='A': pos[0]-=int(i[1]) if i[0]=='D': pos[0]+=int(i[1]) if i[0]=='W': pos[1]+=int(i[1]) if i[0]=='S': pos[1]-=int(i[1]) if len(i)==3: if i[0]=='A' or i[0]=='S' or i[0]=='W' or i[0]=='D': if ord(i[1])>=48 and ord(i[2])>=48 and ord(i[1])<=57 and ord(i[2])<=57: if i[0]=='A': pos[0]-=int(i[1]+i[2]) if i[0]=='D': pos[0]+=int(i[1]+i[2]) if i[0]=='W': pos[1]+=int(i[1]+i[2]) if i[0]=='S': pos[1]-=int(i[1]+i[2]) print("{},{}".format(pos[0],pos[1]))