题解 | #坐标移动#

坐标移动

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

while True:
    try:
        input_str_list = input().split(";")
        start_point = [0, 0]
        
        for each in input_str_list:
            if len(each) <= 1:
                continue
            if each[0] not in ["A", "S", "W", "D"]:
                continue
            
            char_count = 0
            for each_char in each:
                if each_char.isalpha():
                    char_count += 1
                if char_count > 1:
                    continue
            if char_count > 1:
                continue
            
            orientation = each[0]
            num = int(each[1:])
            if orientation == "A":
                start_point[0] = start_point[0] - num
            elif orientation == "D":
                start_point[0] = start_point[0] + num
            elif orientation == "W":
                start_point[1] = start_point[1] + num
            elif orientation == "S":
                start_point[1] = start_point[1] - num
            else:
                pass
        
        print(str(start_point[0]) + "," + str(start_point[1]))
        
        
    except EOFError:
        break

全部评论

相关推荐

10-28 14:42
门头沟学院 Java
watermelon1124:因为嵌入式炸了
点赞 评论 收藏
分享
专心打鱼:互联网搬运工,贴子都要偷
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务