题解 | #坐标移动#python3过滤法

坐标移动

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

data = input().split(';')
e_command=[]
for command in data:
    length = len(command)
    if length == 3 or length == 2:        
        if command[0] in ['A','W','S','D'] and command[1:length].isdigit():
            e_command.append(command)

x,y = 0,0
for i in e_command:
    if i[0] == 'A':
        x += -int(i[1:len(i)])
    if i[0] == 'D':
        x +=  int(i[1:len(i)])
    if i[0] == 'S':
        y += -int(i[1:len(i)])
    if i[0] == 'W':
        y +=  int(i[1:len(i)])

print('%d,%d'%(x,y))
全部评论

相关推荐

半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
05-22 09:23
门头沟学院 Java
点赞 评论 收藏
分享
评论
5
收藏
分享

创作者周榜

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