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 sntk
# migrated from python 2.7
import math
from functools import reduce
def intdist(f,t):
h = f[0] - t[0]
w = f[1] - t[1]
return int(math.sqrt(h**2 + w**2)+0.5)
def candidates(py,px,r):
return [(y,x) for x in range(10) for y in range(10) if intdist((py,px),(y,x)) == r]
def checkio(data):
if len(data) == 0:
return [0,0]
cs = reduce(lambda a, b: a & b, [set(candidates(*x)) for x in data])
return cs.pop()
Feb. 18, 2014
Comments: