Skip to content

Instantly share code, notes, and snippets.

@arikrak
Last active December 10, 2015 09:39
Show Gist options
  • Save arikrak/4415721 to your computer and use it in GitHub Desktop.
Save arikrak/4415721 to your computer and use it in GitHub Desktop.
#Andy's final solution to Sudoku CodeGolf
r=range
t=r(9)
a=r(81)
def s(x):
if x<0:return 1
while(x
and
n[x]):x-=1
for l in t:
n[x]=l+1
if 0==any(i/9==j/9
or
i%9==j%9
or
i/27==j/27
and
i%9/3==j%9/3
for
i
in
a
for
j
in
r(i)if
n[i]and
n[i]==n[j])and s(x-1):return 1
n[x]=0
n=[int(x)for i in range(9) for x in raw_input() if x > ' ']
s(80)
for i in a:print n[i],chr(32-i%9/8*22),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment