Created
December 30, 2012 22:39
-
-
Save arikrak/4415743 to your computer and use it in GitHub Desktop.
Aleksander's solution to Sudoku code golf.
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
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