Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
From neighbors to neighbors with memorisation of previous steps... solution in Clear category for Can You Pass? by Phil15
def distance(a,b):
"""The minimal numbers of steps to go to b from a
(a and b are coordinates tuples).
"""
return abs(a[0]-b[0]) + abs(a[1]-b[1])
def neighbors(grille, me, previous):
"""We list neighbors of me if grille's values are equals
and if we don't have visited them before.
"""
x,y = me
r,c = len(grille), len(grille[0])
return [(u,v) for (u,v) in [(x,y-1),(x,y+1),(x-1,y),(x+1,y)] #Possibles neighbors
if 0<=u
March 28, 2018
Comments: