Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Compass, Map and Spyglass by Tinus_Trotyl
from itertools import permutations
def navigation(seaside):
shortest = 100
position = {item:(x,y) for y, line in enumerate(seaside) for x, item in enumerate(line) if item}
for seq in permutations('CMS'):
begin, length = position['Y'], 0
for object in seq:
end = position[object]
length += max(abs(begin[0] - end[0]), abs(begin[1] - end[1]))
shortest = min(shortest, length)
return shortest
Sept. 5, 2018