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 kurosawa4434
def navigation(seaside):
coordinate = lambda x: [(i, row.index(x)) for i, row in enumerate(seaside) if x in row][0]
y, c, m, s = map(coordinate, 'YCMS')
return sum(max(abs(a-b) for a, b in zip(y, i)) for i in (c, m, s))
if __name__ == '__main__':
print("Example:")
print(navigation([['Y', 0, 0, 0, 'C'],
[ 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0],
['M', 0, 0, 0, 'S']]))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert navigation([['Y', 0, 0, 0, 'C'],
[ 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0],
['M', 0, 0, 0, 'S']]) == 11
print("Coding complete? Click 'Check' to earn cool rewards!")
Sept. 5, 2018
Comments: