Created
April 5, 2017 21:57
-
-
Save fserb/888ea7dfaa39bdbd308d938cf3b17589 to your computer and use it in GitHub Desktop.
spiral.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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