Skip to content

Instantly share code, notes, and snippets.

@arikrak
Created December 30, 2012 22:39
Show Gist options
  • Save arikrak/4415743 to your computer and use it in GitHub Desktop.
Save arikrak/4415743 to your computer and use it in GitHub Desktop.
Aleksander's solution to Sudoku code golf.
g=[1..9]
x=[(i,j)|i<-g,j<-g]
main=interact$(\s->unlines[unwords[show$s(i,j)!!0|j<-g]|i<-g]).head.s.i
s r=foldr(\p l->[m(p,n)r|r<-l,n<-r p])r x
e a b=div(a-1)3==div(b-1)3
m(p@(i,j),n)s q@(x,y)|p==q=[n]|x==i||y==j||e x i&&e y j=filter(/=n)$s q|True=s q
i s=[foldr m(\_->g)[w|w<-zip x$map read$words s,snd w>0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment