题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
# A10;S20;W10;D30;X;A1A;B10A11;;A10; s = input() list_str = s.split(';') x = 0 y = 0 direction_zy = {"A": -1, "D": 1} direction_sx = {"W": 1, "S": -1} direction = dict(direction_zy) direction.update(direction_sx) for i in range(len(list_str)-1): str = list_str[i] if len(str)==0 or len(str)>3: continue if str[0] not in direction.keys(): continue try: number = int(str[1:]) except: number = -1 if number>=0: if str[0] in direction_sx.keys(): y = y + direction[str[0]] * number else: x = x + direction[str[0]] * number print(f'{x},{y}')渣渣的写法,哈哈,打卡的第一题,留个笔
#字节测试开发一面面经#