Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
cmp solution in Clear category for Colder-Warmer by DiZ
def checkio(steps):
global candidates
if len(steps) < 2:
candidates = {(i, j) for i in range(10) for j in range(10)}
else:
def cmp(u, v):
d0, d1 = ((u - i)**2 + (v - j)**2 for i, j, _ in steps[-2:])
return d0 > d1 or - (d0 < d1)
candidates = {(i, j) for i, j in candidates if cmp(i, j) == steps[-1][-1]}
return candidates.pop()
April 20, 2015
Comments: