题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
lst = input().split(';') move = {'A': (-1, 0), 'D':(1,0), 'S':(0,-1), 'W':(0,1)} position = [0, 0] for i in lst: try: d = i[0] # 方向 t = int(i[1:]) # 步数 for j in range(2): # 行动(最关键的算法) position[j] += move[i[0]][j] * t except: continue print(str(position[0])+','+str(position[1]))