题解 | #坐标移动#

坐标移动

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

input_list = input().split(";")
init = [0, 0]
derect = "AWSD"
for item in input_list:
    if len(item) <= 0:
        continue
    derection = item[0]
    steps = item[1::]
    if derection in derect and steps.isdigit():
        if derection == "A":
            init[0] -= int(item[1::])
        elif derection == "D":
            init[0] += int(item[1::])
        elif derection == "W":
            init[1] += int(item[1::])
        elif derection == "S":
            init[1] -= int(item[1::])
    else:
        continue
print(str(init[0]) + "," + str(init[1]))
全部评论

相关推荐

10-09 22:05
666 C++
找到工作就狠狠玩CSGO:报联合国演讲,报电子烟设计与制造
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务