選択できるのは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]))})