题解 | 坐标移动

坐标移动

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



while True:
    try:
        s = input().split(";")
        point = [0, 0]
        std = ["A", "S", "W", "D"]
        for i in s:
            if not 2 <= len(i) <= 3:
                continue
            a = i[0]
            if not i[1:].isdigit():
                continue
            b = int(i[1:])
            if a in std:
                if a == "A":
                    point[0] -= b
                elif a == "D":
                    point[0] += b
                elif a == "S":
                    point[1] -= b
                elif a == "W":
                    point[1] += b
        print(",".join(map(str, point)))
    except:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务