Skip to content

Instantly share code, notes, and snippets.

@vonWolfehaus
Created May 28, 2013 01:01
Show Gist options
  • Save vonWolfehaus/5659891 to your computer and use it in GitHub Desktop.
Save vonWolfehaus/5659891 to your computer and use it in GitHub Desktop.
def spiral(X, Y):
x = y = 0
dx = 0
dy = -1
for i in range(max(X, Y)**2):
if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
print (x, y)
# DO STUFF...
if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
dx, dy = -dy, dx
x, y = x+dx, y+dy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment