Get the latest tech news
Arthur Whitney's one liner sudoku solver (2011)
Dyalog APL
Technical notes: This solution was supplied by Veli-Matti Jantunen, who says: ⍺ may be used to denote the sudoku rectangle, the default is 2/(↑⍴⍵)*0.5 (eg. sudoku←{ ⍝ Define one k fn and one op missing from APL wh←{⍸⍵≠0} ⍝ k '&' function mg←{a←⍺ ⋄ a[⍺⍺]←⍵ ⋄ a} ⍝ merge operator: r←old (indexes mg) new rcq←(↑,⍳9 9),3/,3⌿3 3⍴⍳9 ⍝ Row, Column, Quadrant p←{wh rcq∨.=⍵}¨↓rcq ⍝ Cells in same row, col or quadrant nzd←1+⍳9 ⍝ Non-zero digits for a little more speed ⊃{⊃,/⍺{⍵∘(⍺ mg)¨nzd~⍵[⍺⊃p]}¨⍵}/(wh ⍵=0),⊂⊂⍵ ⍝ kapow! } svec ← {⊃pvex/(emt ⍵),⊂⊂⍵} ⍝ solution vector pvex ← {⊃,/⍺∘pvec¨⍵} ⍝ vector of placements pvec ← {(⍺ avl ⍵)⊣@(⊂⍺)¨⊂⍵} ⍝ placements avl ← {(⍳⊃⍴⍵)~⍵×⊃⍺⌷CMAP} ⍝ list of available numbers emt ← {(,⍵=0)/,⍳⍴⍵} ⍝ row & column indices of empty cells rcb ← {(⍳⍴⍵),¨⍺ box(⍴⍵)÷⍺} ⍝ row/column/box numbers box ← {(⊃⍺)⌿(⊃⌽⍺)/⍵⍴⍳×/⍵} ⍝ box numbers for a puzzle of size ⍵*2 cmap ← {⊂[⍳2]1∊¨⍵∘.=⍵} ⍝ contention map for puzzle ⍵ CMAP ← cmap ⍺ rcb ⍵ ⍝ contention map for puzzle svec ⍵ ⍝ vector of solutions. }
Or read this on Hacker News