Skip to content

Instantly share code, notes, and snippets.

@arikrak
Created December 30, 2012 22:37
Show Gist options
  • Save arikrak/4415733 to your computer and use it in GitHub Desktop.
Save arikrak/4415733 to your computer and use it in GitHub Desktop.
r=range
def f(s):
x=s.find('0')
if not~x:print s;exit()
[c in[(x-y)%18*(x/18^y/18)*(x/54^y/54|x%18/6^y%18/6)or s[y]for y in r(0,162,2)]or f(s[:x]+c+s[x+1:])for c in'123456789']
f('\n'.join(raw_input()for x in r(9)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment