题解 | #坐标移动#

坐标移动

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

list1 = [0, 0]
list2 = ["A", "D", "S", "W"]
list3 = input().split(";")

for st in list3:
    num = len(st)
    if 2 <= num <= 3:
        if st[0] in list2:
            try:
                t = int(st[1:])
            except:
                continue
            if st[0] == "A":
                list1[0] -= t
            elif st[0] == "D":
                list1[0] += t
            elif st[0] == "W":
                list1[1] += t
            else:
                list1[1] -= t
    else:
        continue

print(f"{list1[0]},{list1[1]}")

全部评论

相关推荐

秋招投简历提醒助手:个人经验是,一般面二十场左右就会进入侃侃而谈阶段。我今年七月末的时候开始的第一次面试,都是很多不会,回复很慢。后面慢慢迭代,到九月中的时候基本上面啥说啥,很放松的状态
远程面试的尴尬瞬间
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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