Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ore In The Desert by tokiojapan55
from itertools import product
def checkio(previous):
distance = lambda a,b:round(((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5)
matrix = [[1]*10 for _ in range(10)]
for p in previous:
for r,c in product(range(10),range(10)):
if distance((p[0],p[1]),(r,c))!=p[2]:
matrix[r][c] = 0
result = [[r,c] for r,c in product(range(10),range(10)) if matrix[r][c]]
if len(result)<=3:
return result[0]
return [[0,0],[9,0],[0,9],[9,9]][len(previous)]
June 2, 2020
Comments: