Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Colder-Warmer by tokyoamado
def checkio(steps):
ps = {(x, y) for x in range(10) for y in range(10)}
r, c, _ = steps[0]
if len(steps) > 1:
for r1, c1, t1 in steps[1:]:
ps = ps.intersection(possibles((r, c), (r1, c1), t1))
r, c = r1, c1
return max(ps, key=lambda x: dist((r, c), x))
dist = lambda p0, p1: sum(map(lambda x0, x1: (x1 - x0) ** 2, p0, p1))
sign = lambda x: (x > 0) - (x < 0)
def possibles(before, after, temp):
return {(x, y)
for x in range(10)
for y in range(10)
if sign(dist((x, y), before) - dist((x, y), after)) == temp}
Jan. 2, 2018
Comments: