您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

8 行
232B

  1. from itertools import accumulate as acc
  2. text = data_file.read_text()
  3. dirs = dict(zip('<>^v', [-1, 1, -1j, 1j]))
  4. ans1 = len({*acc(map(dirs.get, text))})
  5. ans2 = len({*acc(map(dirs.get, text[::2])), *acc(map(dirs.get, text[1::2]))})