题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
list1 = [0, 0]
list2 = ["A", "D", "S", "W"]
list3 = input().split(";")
for st in list3:
num = len(st)
if 2 <= num <= 3:
if st[0] in list2:
try:
t = int(st[1:])
except:
continue
if st[0] == "A":
list1[0] -= t
elif st[0] == "D":
list1[0] += t
elif st[0] == "W":
list1[1] += t
else:
list1[1] -= t
else:
continue
print(f"{list1[0]},{list1[1]}")
腾讯云智研发成长空间 5057人发布