Skip to content

Instantly share code, notes, and snippets.

@fserb
Created April 5, 2017 21:57
Show Gist options
  • Save fserb/888ea7dfaa39bdbd308d938cf3b17589 to your computer and use it in GitHub Desktop.
Save fserb/888ea7dfaa39bdbd308d938cf3b17589 to your computer and use it in GitHub Desktop.
spiral.py
#!/usr/bin/python
def getSpiral(n):
out = []
for d in range(n+1):
for x in range(-d, d+1):
out.append((x, -d))
if d != 0:
out.append((x, d))
for y in range(-d+1, d):
out.append((-d, y))
out.append((d, y))
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment