题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
string = input()
groups = string.split(';')
count = []
for g in groups:
if len(g) == 3 and g[1] >= '0' and g[1] <= '9' and g[2] >= '0' and g[2] <= '9':
count.append(g)
elif len(g) == 2 and g[1] >= '0' and g[1] <= '9':
count.append(g)
l, r = 0, 0
for c in count:
if c[0] == 'A':
l -= int(c[1:])
elif c[0] == 'D':
l += int(c[1:])
elif c[0] == 'W':
r += int(c[1:])
elif c[0] == 'S':
r -= int(c[1:])
print(f'{l},{r}')