题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import sys def zuobiao(input_str): input_str = input_str.split(";") x,y=0,0 for i in input_str: if len(i) < 2 or len(i) > 3: continue dire = i[0] if not dire in "AWSD": continue num = i[1:] if not num.isdigit(): continue des = int(num) if dire == "A": x -= des elif dire == "D": x += des elif dire =="W": y += des elif dire == "S": y -= des return f"{x},{y}" input_data = sys.stdin.read().strip() print(zuobiao(input_data))