Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Wat? solution in Speedy category for Square Spiral by veky
def find_distance(*points):
def coord(z):
z -= 1
r = int(z ** .5 * .5 + .5)
z -= 1
try:
s, q = divmod(z, r * 2)
s -=~- r
q -=~- r
s -=~- r
return (q, r, -q, -r, q)[s:][:2]
except ZeroDivisionError: return r, r
return sum(map(abs, map(int.__sub__, *map(coord, points))))
Aug. 16, 2014
Comments: