Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Colder-Warmer by freeman_lex
from math import hypot
field = [[r, c] for r in range(10) for c in range(10)]
def checkio(steps):
global field
x1, y1, d = steps[-1]
field.remove([x1, y1])
if len(steps) > 1:
x2, y2, _ = steps[-2]
field = {1: [[x, y] for x, y in field
if hypot(x1 - x, y1 - y) < hypot(x2 - x, y2 - y)],
0: [[x, y] for x, y in field
if hypot(x1 - x, y1 - y) == hypot(x2 - x, y2 - y)],
-1: [[x, y] for x, y in field
if hypot(x1 - x, y1 - y) > hypot(x2 - x, y2 - y)]}[d]
return field[len(field) // 2]
Aug. 17, 2016
Comments: