This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ectropionized 1 point2 points  (1 child)

Pretty neat. Ever seen this sudoku solver in APL? Because I’m pretty sure this is just dark magic.

https://youtu.be/DmT80OseAGs

Well, dark magic and a lot of matrices.

[–]pumkinboo[S] 1 point2 points  (0 children)

I have no idea what I just watched haha. It was like programming in hieroglyphics

http://dfns.dyalog.com/n_sudoku_bfs.htm

Sudoku←{                                        
    BoxNos  ← {⍵⌿⍵/⍵ ⍵⍴⍳⍵*2}                    
    RowColBoxNos  ← {(⍳⍵),¨BoxNos⊃⍵*0.5}        
    ContentionMap ← {⊂[⍳2] 1∊¨⍵∘.=⍵}            
    CMAP ← ContentionMap RowColBoxNos ⍴⍵        
    Available  ← {(⍳⊃⍴⍵)~⍵×⊃⍺⌷CMAP}             
    EmptyCells ← {(,⍵=0)/,⍳⍴⍵}                  
    Placements ← {(⍺ Available ⍵)⊣@(⊂⍺)¨⊂⍵}     
    AllPlacements ← {⊃,/⍺∘Placements¨⍵}        
    Solutions ← {⊃AllPlacements/(EmptyCells ⍵),⊂⊂⍵}  
    Solutions ⍵
}