题解 | #坐标移动#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
我还以为要用自动机,结果用try语句就可以了
lst = input().split(';')[:-1]
x, y = (0, 0)
for i in lst:
try:
num = int(i[1:])
if i[0] in 'ASDW':
if i[0] == 'A': x -= num
elif i[0] == 'S': y -= num
elif i[0] == 'D': x += num
elif i[0] == 'W': y += num
else: pass
except: pass
print(str(x)+','+str(y))