题解 | #坐标移动#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
用了sys.stdin来处理多组样例
import sys
for line in sys.stdin:
alist=line.strip().split(';')
blist=[0,0]
for each in alist:
if 2<=len(each)<=3 and (each[0] in "ASWD")and each[1:].isdigit():
if each[0]=='A':
blist[0]=blist[0]-int(each[1:])
if each[0]=='S':
blist[1]=blist[1]-int(each[1:])
if each[0]=='W':
blist[1]=blist[1]+int(each[1:])
if each[0]=='D':
blist[0]=blist[0]+int(each[1:])
print(blist[0],end=",")
print(blist[1],end="")