瀏覽代碼

2017.11

master
Roderic Day 3 年之前
父節點
當前提交
006b81ceed
共有 1 個檔案被更改,包括 15 行新增0 行删除
  1. +15
    -0
      y2017/p11.py

+ 15
- 0
y2017/p11.py 查看文件

steps = {
'n': (1, 0),
's': (-1, 0),
'ne': (0.5, 0.5),
'se': (-0.5, 0.5),
'nw': (0.5, -0.5),
'sw': (-0.5, -0.5),
}
x, y = 0, 0
ans2 = 0
for dx, dy in map(steps.get, data_file.read_text().strip().split(',')):
x, y = x + dx, y + dy
dist = int(abs(x) + abs(y))
ans2 = max(ans2, dist)
ans1 = dist

Loading…
取消
儲存