题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
from re import I import sys #for line in sys.stdin: # a = line.split() # print(int(a[0]) + int(a[1])) #L=[] L=input().split(";") direction=[] distance=[] #print(L) for x in L: if x!="": if x[0] in "WSAD" and (x[1:]).isdigit(): direction.append(x[0]) distance.append(int(x[1:])) else: pass #print(direction) #print(distance) #l=zip(direction,distance) x=0 y=0 for i,j in zip(direction,distance): # print(i,j) if i=="A": # print("**********************") x=x-j # print(x) if i=="D": x=x+j if i=="W": y=y+j if i=="S": y=y-j print(x,y ,sep=",")