题解 | #坐标移动#

坐标移动

https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29

from re import I
import sys

#for line in sys.stdin:
#    a = line.split()
#    print(int(a[0]) + int(a[1]))

#L=[]
L=input().split(";")
direction=[]
distance=[]
#print(L)
for x in L:
    if x!="":
        if x[0] in "WSAD" and (x[1:]).isdigit():
            direction.append(x[0])
            distance.append(int(x[1:]))
        else:
            pass
#print(direction)
#print(distance)
#l=zip(direction,distance)
x=0
y=0
for i,j in zip(direction,distance):
#    print(i,j)
    if i=="A":
#        print("**********************")
        x=x-j
#        print(x)
    if i=="D":
        x=x+j
    if i=="W":
        y=y+j
    if i=="S":
        y=y-j
print(x,y ,sep=",")

全部评论

相关推荐

11-02 09:49
已编辑
货拉拉_测试(实习员工)
热爱生活的仰泳鲈鱼求你们别卷了:没事楼主,有反转查看图片
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务