题解 | #坐标移动#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))
全部评论

相关推荐

兄弟们你们进大厂靠的是什么项目啊
DOTPHTP:课设改。其实项目什么的如果不是实习里面的生产项目的话,建议✍️那种自己想要做的。突出个人自驱力,而不是为了找工作不得不随波逐流这种
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
评论
5
收藏
分享

创作者周榜

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