题解 | #坐标移动#

坐标移动

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

import sys
import re

a= input()
start = [0,0]
b = a.split(';')
oper = ['A','D','W','S']
for i in b:
    if not 2 <=len(i)<=3:
        continue
    try:
        if i[0] in oper:
            step = int(i[1:])
            if 0<= step <100:
                if i[0] == 'A':
                    start[0] -= step
                elif i[0] == 'D':
                    start[0] += step
                elif i[0] == 'S':
                    start[1] -= step
                elif i[0] == 'W':
                    start[1] += step
    except:
        continue
print(str(start[0])+','+str(start[1]))

全部评论

相关推荐

头像
05-16 11:16
已编辑
东华理工大学 Java
牛客737698141号:盲猜几十人小公司,庙小妖风大,咋不叫她去4️⃣呢😁
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务