Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Long edge of submatrix solution in Clear category for Compass, Map and Spyglass by tokyoamado
from itertools import dropwhile
def pos(field, char):
slice = next(dropwhile(lambda x: char not in x, field))
row = field.index(slice)
col = slice.index(char)
return col, row
def dist(field, char1, char2):
p1 = pos(field, char1)
p2 = pos(field, char2)
x, y = abs(p1[0] - p2[0]), abs(p1[1] - p2[1])
return max(x, y)
def navigation(seaside):
dc = dist(seaside, 'Y', 'C')
dm = dist(seaside, 'Y', 'M')
ds = dist(seaside, 'Y', 'S')
return dc + dm + ds
Sept. 28, 2018