Explorar el Código

2017.11

master
Roderic Day hace 3 años
padre
commit
006b81ceed
Se han modificado 1 ficheros con 15 adiciones y 0 borrados
  1. +15
    -0
      y2017/p11.py

+ 15
- 0
y2017/p11.py Ver fichero

@@ -0,0 +1,15 @@
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

Cargando…
Cancelar
Guardar