You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 yıl önce
123456789101112131415
  1. steps = {
  2. 'n': (1, 0),
  3. 's': (-1, 0),
  4. 'ne': (0.5, 0.5),
  5. 'se': (-0.5, 0.5),
  6. 'nw': (0.5, -0.5),
  7. 'sw': (-0.5, -0.5),
  8. }
  9. x, y = 0, 0
  10. ans2 = 0
  11. for dx, dy in map(steps.get, data_file.read_text().strip().split(',')):
  12. x, y = x + dx, y + dy
  13. dist = int(abs(x) + abs(y))
  14. ans2 = max(ans2, dist)
  15. ans1 = dist