Skip to content

Instantly share code, notes, and snippets.

@dps
Created September 5, 2015 09:15
Show Gist options
  • Save dps/75f3589a9b73a46c57f1 to your computer and use it in GitHub Desktop.
Save dps/75f3589a9b73a46c57f1 to your computer and use it in GitHub Desktop.
A short Sudoku solver in Scala. By Muntis Grube
def s(l:String):Unit={val i=l indexOf '0'
if(i<0)println(l)else
for{c<-'1'to'9'
if(0 to 80).forall(n=>((n-i)%9*(n/9^i/9)*(n/27^i/27|n%9/3^i%9/3)|l(n)^c)!=0)}
s(l.replaceFirst("0",""+c))}
s(args(0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment