import re def calculate_final_position(moves): # 初始坐标 x, y = 0, 0 # 方向映射 direction_map = {'A': (-1, 0), 'D': (1, 0), 'W': (0, 1), 'S': (0, -1)} # 正则表达式匹配合法坐标 pattern = re.compile(r'^([ADWS])(\d{1,2})$') for move in moves.split(';'): match = pattern.match(move) ...