Skip to content

Instantly share code, notes, and snippets.

@zrnsm
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zrnsm/3c00ce870128e4176ce3 to your computer and use it in GitHub Desktop.
Save zrnsm/3c00ce870128e4176ce3 to your computer and use it in GitHub Desktop.
Spiral Golf
n,r,c=31,range,'x '
s=map(r,[n]*n)
def f(x):
q=r(x,n-x)
for i in q:
for j in q:s[i][j]=c[x%2]
for i in r(0,n/2,2):f(i),f(i+1);s[i+2][i+1],s[i+1][i]=c
for r in s:print ' '.join(r)
@yosun
Copy link

yosun commented Feb 13, 2015

@yosun
Copy link

yosun commented Feb 13, 2015

@KirarinSnow
Copy link

Shrunken to 99 chars!!!

@KirarinSnow
Copy link

Now 93 chars!!!

@KirarinSnow
Copy link

Now 87!!

@KirarinSnow
Copy link

If the size (an odd integer) is read in through stdin, then 95 chars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment