Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
*Colder-Warmer solution in Clear category for Colder-Warmer by JimmyCarlos
from math import hypot
def checkio(steps):
possible = [(x,y) for x in range(10) for y in range(10)]
for i in range(len(steps)-1):
step1_x,step1_y = steps[i][:2]
step2_x,step2_y,temp_change = steps[i+1]
if temp_change == -1:
possible = [(x,y) for x,y in possible if hypot(x-step2_x,y-step2_y) > hypot(x-step1_x,y-step1_y)]
elif temp_change == 0:
possible = [(x,y) for x,y in possible if hypot(x-step2_x,y-step2_y) == hypot(x-step1_x,y-step1_y)]
elif temp_change == 1:
possible = [(x,y) for x,y in possible if hypot(x-step2_x,y-step2_y) < hypot(x-step1_x,y-step1_y)]
x_last,y_last = steps[-1][:2]
return max(possible,key=lambda coord:hypot(coord[0]-x_last,coord[1]-y_last))
June 9, 2019
Comments: