Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
islice(cycle) solution in Clear category for Fibonacci Spiral's End by Phil15
import itertools as it
def fibo_spiral_end(n: int) -> list[int]:
x = y = 0
u, v = 0, 1
for dx, dy in it.islice(it.cycle([(1, -1), (1, 1), (-1, 1), (-1, -1)]), n):
x += dx * v
y += dy * v
u, v = v, u + v
return [x, y]
Jan. 5, 2023