题解 | #坐标移动#

坐标移动

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

values = input().split(';')
beg = [0,0]
for value in values:
    try:
        if 2<= len(value) <= 3 and 0 <= int(value[1:]) <=99:
            if value[0] == 'A':
                beg[0] = beg[0]-int(value[1:])
            elif value[0] == 'S':
                beg[1] = beg[1]-int(value[1:])
            elif value[0] == 'D':
                beg[0] = beg[0]+int(value[1:])
            elif value[0] == 'W':
                beg[1] = beg[1]+int(value[1:])
    except:
        continue
print(str(beg[0]) + ',' + str(beg[1]))
            
全部评论

相关推荐

点赞 评论 收藏
分享
kyw_:接好运
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务