Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Complex solution in Creative category for Square Spiral by Talim42
def find_distance(first, second):
spirale, spin = [complex(0)], 0
while len(spirale) < max(first, second):
for d in (1j, 1, -1j, -1):
exec('spirale += [spirale[-1] + d];' * (spin//2 + 1))
spin += 1
diff = spirale[first - 1] - spirale[second - 1]
return abs(diff.imag) + abs(diff.real)
June 27, 2014
Comments: