题解 | #坐标移动#

坐标移动

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

my_str = input().split(';')
start =[0,0]

for item in my_str:
    if not 2 <= len(item) <= 3:
        continue		#

    try:
        direction = item[0]
        step = int(item[1:])
        if direction in ['A','D','W','S']:
            if 0 <= step <= 99:
                if direction == 'A':
                    start[0] -= step
                elif direction == 'D':
                    start[0] += step
                elif direction == 'W':
                    start[1] += step
                elif direction == 'S':
                    start[1] -= step

    except:
        continue		#

print(str(start[0]) + ',' + str(start[1]))

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-27 20:15
还能挽救吗?找同学帮忙看了一下&nbsp;字节怎么能如此对我
牛客26396789...:你这是严重红线,被发现你自己永远进不去,你那个同学直接走人,你还敢宣扬
点赞 评论 收藏
分享
lllllkin:感觉可以精简到一页简历,有些排版感觉不是必须的。 时间线越早的,你自己越熟悉的放前面。描述可以更精简些,一些问题解决感觉可以不用写具体技术栈,卖个关子,等面试官问。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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