Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
13-liner: normalize distances solution in 3rd party category for Compass, Map and Spyglass by Stensen
import numpy as np
def distance(coords_1, coords_2):
(x1, y1), (x2, y2) = coords_1, coords_2
dX, dY = abs(x2 - x1), abs(y2 - y1)
if x1 == x2: return dY
if y1 == y2: return dX
return max(dX, dY)
def navigation(seaside):
MAP = np.array(seaside)
Y, C, M, S = np.where(MAP == 'Y'), np.where(MAP == 'C'), np.where(MAP == 'M'), np.where(MAP == 'S')
Y, C, M, S = list(map(int, Y)), list(map(int, C)), list(map(int, M)), list(map(int, S))
return distance(Y, C) + distance(Y, M) + distance(Y, S)
Oct. 20, 2021
Comments: