Puzzle du 11 décembre 2017
This commit is contained in:
parent
b6973711e0
commit
e59e8a584f
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
def hex_dist(x, y):
|
||||
return abs(x) + abs(y)
|
||||
|
||||
import sys
|
||||
directions = {'n': [1, 1],
|
||||
'nw': [0, 1],
|
||||
'ne': [1, 0],
|
||||
's': [-1, -1],
|
||||
'sw': [-1, 0],
|
||||
'se': [0, -1]}
|
||||
data = [directions[k] for k in sys.stdin.readline().strip().split(",")]
|
||||
x, y, maxd = 0, 0, 0
|
||||
for d in data:
|
||||
if hex_dist(x + d[0], y + d[1]) > maxd:
|
||||
maxd = hex_dist(x + d[0], y + d[1])
|
||||
x += d[0]
|
||||
y += d[1]
|
||||
|
||||
print(hex_dist(x, y), maxd)
|
||||
|
Loading…
Reference in New Issue