svec ← {shape←⍬⍴(⍴⍵)*÷2} ##.sudoku prob ⍝ Solution vector for Sudoku problem ⍵. The Sudoku puzzle consists of a 3×3 grid of 3×3 boxes, each cell of which is either empty or contains a number in the range 1 to 9. A typical problem might look like this: ┌─────┬─────┬─────┐ │· · 1│6 9 ·│5 · ·│ │4 · ·│2 7 ·│· · 1│ │· 7 ·│· · ·│· 9 ·│ ├─────┼─────┼─────┤ │· · ·│· · ·│· 3 ·│ │· · ·│4 3 ·│· · 7│ │· · ·│7 8 ·│6 · ·│ ├─────┼─────┼─────┤ │· · 6│· · ·│8 · ·│ │· 2 ·│1 4 ·│· 6 ·│ │· 1 ·│3 5 ·│· 4 ·│ └─────┴─────┴─────┘ The challenge is to supply the missing numbers in such a way that: each 3×3 box and each 9-item row and each 9-item column contains each of the 9 numbers with no repeats. A solution to the above problem might be: ┌─────┬─────┬─────┐ │3 8 1│6 9 4│5 7 2│ │4 6 9│2 7 5│3 8 1│ │2 7 5│8 1 3│4 9 6│ ├─────┼─────┼─────┤ │7 9 4│5 6 2│1 3 8│ │6 5 8│4 3 1│9 2 7│ │1 3 2│7 8 9│6 5 4│ ├─────┼─────┼─────┤ │5 4 6│9 2 7│8 1 3│ │9 2 3│1 4 8│7 6 5│ │8 1 7│3 5 6│2 4 9│ └─────┴─────┴─────┘ The puzzle may be generalised to accept problems of shape other than 3×3×3×3, see examples below. Argument matrix [prob] contains numbers 1-9 in occupied cells and 0s otherwise. Optional left argument [shape] specifies the box shape for non-square problems. The result is a vector of all solution matrices. 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. if "mat" is a 6x6 matrix and the sub area is 2 3, the call must be 2 3 sudoku mat). The result is a vector of all the solutions found, or ⍬ (no solutions) or '' (error - should not happen, but if there are zillions of results) The algorithm is simple: handle the matrix as a vector the rows, columns and sudoku areas are denoted by index vectors do the basic checking for the puzzle (i.e. polish) and with the main function check one alternative from the list at time: filter all the possible elements for all the cells if at least one cell is empty = no solution -> take the next from the list if one cell contains more than one number -> select the cell from the tightest group and add every combination (from this cell) to the list if all cells contain one number = solution -> take the next from the list. Veli-Matti also provides this new-from-old problem shuffler: Shuffle←{ ⍝| Shuffle the original sudoku table to another one ;) ⍝| ⍺: sudoku box (use for e.g. 6x6 tables, like 2 3 Shuffle table). ⍺←(⍴⍵)*0.5 ⋄ (⎕IO ⎕ML ⎕RL)←1 3(⎕TS+.*2) (¯1+?3⍴2){(⌽⍣(↑⍺))(⍉⍣(↑1⌽⍺))(⊖⍣(↑⌽⍺))⍵}⍵{(0,(↑⍴⍺)?↑⍴⍺)[⍵⌷⍺+1]}(↑⍴⍵){∊{⍵[(⍴⍵)?⍴⍵]}{⍵[(⍴⍵)?⍴⍵]}¨⍵⊂⍳⍺}¨⍺/¨⍳¨⌽⍺ } David Crossley supplies an alternative coding: sudoku←{⎕IO←0 ⍝ Sudoku - ⍵: N×N setup where box size N*÷2 is integral ⍝ The setup is a valid arrangement in some cells of numbers from 1-N; the rest are 0´s. ⍝ Each row, column and the N boxes of each result must contain all numbers 1 to N. · valid←{ ⍝ Validate. ⍵ be... (2≠⍴⍴⍵)∨(≠/2↑⍴⍵)∨0≠1|(⊃⍴⍵)*÷2:1 ⍝ a square matrix with an integral box size ((⍴⍵)⍴0)≢⊃1↑0⍴⊂⍵:1 ⍝ numeric N×N matrix 1∊~⍵∊⍳1+⊃⍴⍵:1 ⍝ numbers 0-N only 0=+/,⍵ ⍝ at least one number } box←{⍵⌿(⍵×⍳⍵)∘.+⍵/⍳⍵} ⍝ Box template ⍵:sq root of size chk←{1∊1<+⌿(1+⍳⊃⍴⍵)∘.=⍵} ⍝ Check for duplicates of 1-9 in ⍵ sets←{⍉⍺{(⍺=+⌿⍵)/⍵}(⍵⍴2)⊤⍳2*⍵} ⍝ LM sets of ⍺ unique nrs from 1 to ⍵ iv←{⍵/⍳⍴⍵} ⍝ idiom un←{(⍳⍴⍵)=⍵⍳⍵} ⍝ LV of first unique items in vector indx←{⍺[⍵]} ⍝ index ⍺ by ⍵ search←{ ⍝ Search possibilities for a cell r p←⍵ p←⍺ adjust p ⍝ adjust possibles for current cell ~0∊⊃(r p)←rules r p:r ⍝ resolve using logical tests (next p)∇¨⊂r p ⍝ search cell with minimum possibilities } adjust←{ ⍝ Adjust cell to single value 0>⊃⍺:⍵ ⍝ no cell p←⍵ ⋄ p[;⊃⍺]←⍺[1]=⍳⊃⍴⍵ ⋄ p ⍝ item ⍺ in to 1, rest of cell to 0 } next←{ ⍝ Cell-value pairs for possible values ⍵{⍵,¨iv ⍺[;⍵] ⍝ in the cell with the minimum nr of }{1⍳⍨⍺\{⍵=⌊/⍵}⍺/⍵}/{(⍵>1)⍵}+⌿⍵ ⍝ possibilities (2 or more) } rules←{ ⍝ Apply logic tests to resolve cells ~0∊⊃z←sole ⍵:z ⍝ detect single-value possibilities ~0∊⊃z←↑singles/(⍳⊃⍴RCB),⊂z:z ⍝ single-valued cells in row/col/box ~0∊⊃z←↑uniques/(⍳(⍴⊃z)*÷2),⊂z:z ⍝ values unique to one row/col of a box ~0∊⊃z←↑NinN/4 3 2,⊂z:z ⍝ detect N vals in N cells ~0∊⊃z←↑matches/4 3 2,⊂z:z ⍝ matches of N vals in N cells of r/c/b z≡⍵:⍵ ⍝ finish if no state change ∇ z ⍝ otherwise repeat rules } sole←{ ⍝ Resolve sole value cells. ⍺:soln, ⍵:possibles ~0∊⊃r p←⍵:⍵ ⍝ pass through 0∊n←+⌿p:⍬ ⍬ ⍝ no go (⍴r)=i←1⍳⍨n×r=0:⍵ ⍝ no remaining single value cells r[i]←1+p[;i]⍳1 ⍝ set result value p[¯1+i⊃r;i~⍨iv i⊃Masks]←0 ⍝ remove as possible value in related cells ∇ r p ⍝ check for further single-value cells } singles←{ ⍝ Fix box cells that resolve to single value ~0∊⊃r p←⍵:⍵ ⍝ pass through i←RCB[⍺;] ⍝ cells in row, col or box b←i/p ⍝ possibles for cells ~1∊l←(1=+/b)∧~(1+⍳⊃⍴p)∊i/r:⍵ ⍝ values that occur just once ex result values c←(iv i)[(↓l⌿b)⍳¨1] ⍝ cells where they occur p[;c]←(⍳⊃⍴p)∘.=iv l ⍝ modify to just the single value sole r p ⍝ resolve the sole values } uniques←{ ⍝ Unique to one row/col of the ⍺´th box ~0∊⊃r p←⍵:⍵ ⍝ pass through b←p[;⍺⊃Box] ⍝ box cell values i←(⍴i)⊤iv,(i>1)∧i=⍉(⌽⍴i)⍴+/i←+/b ⍝ 2 or more unique to a row j←(⍴j)⊤iv,(j>1)∧j=⍉(⌽⍴j)⍴+/j←+/[1]b ⍝ 2 or more unique to a column (0∊⍴i)∧0∊⍴j:⍵ ⍝ none found s←⊃⌽⍴b ⍝ box size p[(s(⍺ rinds)↓i),s(⍺ cinds)↓j]←0 ⍝ remove vals from cols of other boxes sole r p ⍝ resolve sole values } rinds←{ ⍝ uniques: row pick inds to update 0=⍴⊃⍵:0⍴⊂0 0 ↑,/(0⊃⍵),¨¨((⍺*2)×(1⊃⍵)+¨⍺×⌊⍺⍺÷⍺)+⊂(⍳⍺*2)~(⍺×⍺|⍺⍺)+⍳⍺ } cinds←{ ⍝ uniques: column pick inds to update 0=⍴⊃⍵:0⍴⊂0 0 ↑,/(0⊃⍵),¨¨((1⊃⍵)+¨⍺×⍺|⍺⍺)+⊂(⍺*2)×(⍳⍺*2)~(⍺×⌊⍺⍺÷⍺)+⍳⍺ } matches←{ ⍝ Resolve exact matches on ⍺ possible values ~0∊⊃r p←⍵:⍵ ⍝ pass through 0∊n←+⌿p:⍬ ⍬ ⍝ no go if no possibilities for a cell i←(n=⍺){iv ⍺\un 2⊥⍺/⍵}p ⍝ cells with ⍺ possible values sole↑(⍺ match)/i,⊂⍵ ⍝ resolve each ⍺-set then sole values } match←{ ⍝ Resolve exact matches in row/col/box ~0∊⊃r p←⍵:⍵ ⍝ pass through ⍺⍺≠+/p[;⍺]:⍵ ⍝ cell no longer has ⍺⍺ values ⍺⍺>+/l←p[;⍺]∧.=p:⍵ ⍝ occurrences of matches with the ⍺´th cell 1∊⍺⍺<n←+/l/RCB:⍬ ⍬ ⍝ no go if >⍺⍺ matches in any row/col/box ~1∊n=⍺⍺:⍵ ⍝ no r/c/b´s with exactly ⍺⍺ matches p←↑(l do_matches)/(iv n=⍺⍺),⊂p ⍝ remove matched vals from related cells sole r p ⍝ resolve singles then sole values } do_matches←{ ⍝ Remove vals from other row/col/box cells p←⍵ ⍝ ⍺⍺ marks all occurrences of match p[iv p[;⍺⍺⍳1];iv RCB[⍺;]∧~⍺⍺]←0 ⍝ filter occurrences in the ⍺´th row/col/box p } NinN←{ ⍝ Reduce ⍺-sets in exactly ⍺ cells of a row/col/box ~0∊⊃r p←⍵:⍵ ⍝ pass through s←⍺ sets(⍴r)*÷2 ⍝ all combns of sets of ⍺ values l←r=0 ⍝ non-singular cells n←(⍺=(s∨.∧p)+.∧⍉RCB)∧⍺=(s∨.∧l\l/p)+.∧⍉RCB ⍝ set-RCB combinations with ⍺ occurrences i←↓[0](⍴n)⊤iv,n ⍝ indices of set-RCB combns sole↑(s do_NinN)/i,⊂⍵ ⍝ reduce non-set values from cells then sole values } do_NinN←{ ⍝ Remove values not in set ⊃⍺ from identified cells i←⍺⍺[0⊃⍺;] ⋄ j←RCB[1⊃⍺;] ⍝ set values / row-col-box mask r p←⍵ ⋄ p[iv~i;iv j∧i∨.∧p]←0 ⋄ r p ⍝ [vals not in set;cells in set and in row/col/box] } setup←{ ⍝ Setup LM possibilities per cell p←(⊂1+⍳⊃⍴⍵)~¨Masks/¨⊂,⍵ ⍝ possibles per cell, except... ((0≠,⍵)/p)←0~⍨,⍵ ⍝ adjust given cells to single value (1+⍳⊃⍴⍵)∘.∊p ⍝ convert to LM vals×cells } res←(⍴⍵)∘{⍺∘⍴¨((⍴⍵)⍴(×/⍺)↑1)⊂⍵} ⍝ Shape result(s) · valid ⍵:'Invalid setup' ⍝ Validate RCB←{,¨(⍵/⍳⍵)(⍵ ⍵⍴⍳⍵)(box ⍵*÷2)}⊃⍴⍵ ⍝ Rows-Columns-Boxes Masks←↓↑∨/{⍵∘.=⍵}¨RCB ⍝ Sets per cell of related row/col/box cells RCB←↑⍪/(⊂⍳⊃⍴⍵)∘.=¨RCB ⍝ Selection vectors for rows,columns,boxes Box←((⍴⍵)*÷2)∘⍴¨(↓RCB[(2×⊃⍴⍵)+⍳⊃⍴⍵;])/¨⊂⍳×/⍴⍵ ⍝ Box indices 1∊chk¨Masks/¨⊂,⍵:'Invalid setup' ⍝ Duplicates in row/column/box · res∊¯1 0 search(,⍵)(setup ⍵) ⍝: ADC 5Jun2005 } Finally, here is Arthur Whitney's amazing solution in K 5: x(,/{@[x;y;]'(!10)^x*|/p[;y]=p,:,3/:-3!p:!9 9}')/&~*x Translated by Phil Last into a D-function: sudoku←{⎕io←0 ⍝ Whitney/Last p←{(↑⍵)∘{(⍺∨.=⍵)/⍳n×n}¨,⍵},(n*÷2){⍵,⍺⊥⌊⍵÷⍺}¨⍳n n←⍴⍵ m←{(⊂⍵)⌈(⊂⍺=⍳⍴⍵)×(1+⍳n)~⍵[⍺⊃p]} (⍴⍵)∘⍴¨⊃{⊃,/⍺ m¨⍵}/{(⍸⍵=0),⊂⊂⍵},⍵ } Morten Kromberg's recasting defines some of K's constructs explicitly and so is closer to the original. Note that, like the K version, it takes and returns 81- vectors, rather than matrices. 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! } Roger Hui presents this in the following more beautiful form, generalised for non-square puzzles: Sudoku←{⍺←(⍴⍵)*÷2 ⍝ Solutions of shape-⍺ Sudoku puzzle ⍵. 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. } See →sudoku_bfs← for an illustration of this algorithm. See "Learn" in: http://www.TryAPL.org for step-by-step demonstration. Watch: http://www.youtube.com/watch?v=DmT80OseAGs to see it in action. Thanks also to Maurice Jordan and John R. Clark for suggestions. Examples: s33 ⍝ sample 3×3 problem. 0 0 1 6 9 0 5 0 0 4 0 0 2 7 0 0 0 1 0 7 0 0 0 0 0 9 0 0 0 0 0 0 0 0 3 0 0 0 0 4 3 0 0 0 7 0 0 0 7 8 0 6 0 0 0 0 6 0 0 0 8 0 0 0 2 0 1 4 0 0 6 0 0 1 0 3 5 0 0 4 0 sudoku s33 ⍝ ... has 3 solutions. ┌─────────────────┬─────────────────┬─────────────────┐ │3 8 1 6 9 4 5 7 2│2 8 1 6 9 3 5 7 4│2 8 1 6 9 3 5 7 4│ │4 6 9 2 7 5 3 8 1│4 6 9 2 7 5 3 8 1│4 6 9 2 7 5 3 8 1│ │2 7 5 8 1 3 4 9 6│3 7 5 8 1 4 2 9 6│5 7 3 8 1 4 2 9 6│ │7 9 4 5 6 2 1 3 8│7 9 2 5 6 1 4 3 8│7 9 2 5 6 1 4 3 8│ │6 5 8 4 3 1 9 2 7│6 5 8 4 3 9 1 2 7│6 5 8 4 3 9 1 2 7│ │1 3 2 7 8 9 6 5 4│1 3 4 7 8 2 6 5 9│1 3 4 7 8 2 6 5 9│ │5 4 6 9 2 7 8 1 3│5 4 6 9 2 7 8 1 3│3 4 6 9 2 7 8 1 5│ │9 2 3 1 4 8 7 6 5│9 2 3 1 4 8 7 6 5│9 2 5 1 4 8 7 6 3│ │8 1 7 3 5 6 2 4 9│8 1 7 3 5 6 9 4 2│8 1 7 3 5 6 9 4 2│ └─────────────────┴─────────────────┴─────────────────┘ ⍝ This function separates inner boxes for easier reading: sbox←{⎕IO←0 ⍝ Box sudoku grids. ⍺←(⍴⍵)*÷2 ⍝ default square cells. vp hp←0=⍺|⍳¨⍴⍵ ⍝ vert and horiz partition vectors. numbs←⍉↑vp∘(⊂[0])¨hp⊂⍵ ⍝ numeric sub-areas. width←2+⌊10⍟⌈/1,,⍵ ⍝ digits per number. fmt←width∘{⍵=0:⌽⍺↑'·' ⋄ ⍺ 0⍕⍵} ⍝ dots for zeros. cells←0 1∘↓¨↑∘(,/)¨fmt¨¨numbs ⍝ char matrix sub-areas. hv←⍺⍴¨⊂¨⌽(⍴⊃cells)/¨'│─' ⍝ vert and horiz boundaries. in←{↑⍺{⍺,⍺⍺,⍵}/⍵} ⍝ ⍺ separates ⍵. (t m b)lr←'┬┼┴' '├┤'in¨∘⊂¨hv ⍝ bordering lines. body←m in⍉¨⊂[1 2]'│'in cells ⍝ collected cells. (⍉body in t b)in lr in¨'┌└' '┐┘' ⍝ boxed grid. } sbox¨ sudoku s33 ⍝ formatted solutions ┌─────┬─────┬─────┐ ┌─────┬─────┬─────┐ ┌─────┬─────┬─────┐ │3 8 1│6 9 4│5 7 2│ │2 8 1│6 9 3│5 7 4│ │2 8 1│6 9 3│5 7 4│ │4 6 9│2 7 5│3 8 1│ │4 6 9│2 7 5│3 8 1│ │4 6 9│2 7 5│3 8 1│ │2 7 5│8 1 3│4 9 6│ │3 7 5│8 1 4│2 9 6│ │5 7 3│8 1 4│2 9 6│ ├─────┼─────┼─────┤ ├─────┼─────┼─────┤ ├─────┼─────┼─────┤ │7 9 4│5 6 2│1 3 8│ │7 9 2│5 6 1│4 3 8│ │7 9 2│5 6 1│4 3 8│ │6 5 8│4 3 1│9 2 7│ │6 5 8│4 3 9│1 2 7│ │6 5 8│4 3 9│1 2 7│ │1 3 2│7 8 9│6 5 4│ │1 3 4│7 8 2│6 5 9│ │1 3 4│7 8 2│6 5 9│ ├─────┼─────┼─────┤ ├─────┼─────┼─────┤ ├─────┼─────┼─────┤ │5 4 6│9 2 7│8 1 3│ │5 4 6│9 2 7│8 1 3│ │3 4 6│9 2 7│8 1 5│ │9 2 3│1 4 8│7 6 5│ │9 2 3│1 4 8│7 6 5│ │9 2 5│1 4 8│7 6 3│ │8 1 7│3 5 6│2 4 9│ │8 1 7│3 5 6│9 4 2│ │8 1 7│3 5 6│9 4 2│ └─────┴─────┴─────┘ └─────┴─────┴─────┘ └─────┴─────┴─────┘ s22 ⍝ sample 2×2 problem. 0 2 3 4 3 0 0 0 2 0 0 0 4 0 0 0 sbox¨ sudoku s22 ⍝ ... has 3 solutions. ┌───┬───┐ ┌───┬───┐ ┌───┬───┐ │1 2│3 4│ │1 2│3 4│ │1 2│3 4│ │3 4│2 1│ │3 4│1 2│ │3 4│1 2│ ├───┼───┤ ├───┼───┤ ├───┼───┤ │2 1│4 3│ │2 1│4 3│ │2 3│4 1│ │4 3│1 2│ │4 3│2 1│ │4 1│2 3│ └───┴───┘ └───┴───┘ └───┴───┘ 3 4 sbox s34 ⍝ sample 3×4 problem. ┌───────────┬───────────┬───────────┐ │ 9 6 · ·│10 · · 8│ 2 · · 4│ │ · 1 · 11│ · 12 · ·│ · · 3 5│ │ · · · ·│ 6 · 7 11│12 · · ·│ ├───────────┼───────────┼───────────┤ │ · · 10 7│ · · · ·│ 4 · 9 ·│ │ 1 · 6 ·│12 11 · 4│ · 3 · ·│ │ · · 9 ·│ · 10 8 1│ · · 6 ·│ ├───────────┼───────────┼───────────┤ │ · 7 · ·│11 2 1 ·│ · 12 · ·│ │ 2 · 12 ·│ 4 · 6 5│ · 1 · 11│ │ · 10 · 5│ · · · ·│ 3 4 · ·│ ├───────────┼───────────┼───────────┤ │ · · · 10│ 5 8 · 7│ · · · ·│ │ 5 3 · ·│ · · 11 ·│ 9 · · ·│ │ 7 · · ·│ 3 · · 6│ · · 4 2│ └───────────┴───────────┴───────────┘ 3 4∘sbox¨ 3 4 sudoku s34 ⍝ ... has 2 solutions. ┌───────────┬───────────┬───────────┐ ┌───────────┬───────────┬───────────┐ │ 9 6 5 12│10 1 3 8│ 2 7 11 4│ │ 9 6 5 12│10 1 3 8│ 2 7 11 4│ │ 8 1 7 11│ 9 12 4 2│ 6 10 3 5│ │ 8 1 7 11│ 9 12 4 2│ 6 10 3 5│ │10 4 2 3│ 6 5 7 11│12 9 1 8│ │10 4 2 3│ 6 5 7 11│12 9 1 8│ ├───────────┼───────────┼───────────┤ ├───────────┼───────────┼───────────┤ │12 11 10 7│ 2 6 5 3│ 4 8 9 1│ │12 11 10 7│ 2 6 5 3│ 4 8 9 1│ │ 1 2 6 8│12 11 9 4│ 7 3 5 10│ │ 1 2 6 8│12 11 9 4│10 3 5 7│ │ 3 5 9 4│ 7 10 8 1│11 2 6 12│ │ 3 5 9 4│ 7 10 8 1│11 2 6 12│ ├───────────┼───────────┼───────────┤ ├───────────┼───────────┼───────────┤ │ 4 7 3 6│11 2 1 10│ 5 12 8 9│ │ 4 7 3 6│11 2 1 10│ 5 12 8 9│ │ 2 8 12 9│ 4 3 6 5│10 1 7 11│ │ 2 8 12 9│ 4 3 6 5│ 7 1 10 11│ │11 10 1 5│ 8 7 12 9│ 3 4 2 6│ │11 10 1 5│ 8 7 12 9│ 3 4 2 6│ ├───────────┼───────────┼───────────┤ ├───────────┼───────────┼───────────┤ │ 6 9 4 10│ 5 8 2 7│ 1 11 12 3│ │ 6 9 4 10│ 5 8 2 7│ 1 11 12 3│ │ 5 3 8 2│ 1 4 11 12│ 9 6 10 7│ │ 5 3 8 2│ 1 4 11 12│ 9 6 7 10│ │ 7 12 11 1│ 3 9 10 6│ 8 5 4 2│ │ 7 12 11 1│ 3 9 10 6│ 8 5 4 2│ └───────────┴───────────┴───────────┘ └───────────┴───────────┴───────────┘ See also: queens sudoku_bfs X sudokuX See also: http://www.ams.org/notices/200904/rtx090400460p.pdf See also: http://www.TryAPL.org See also: http://www.youtube.com/watch?v=DmT80OseAGs Back to: contents Back to: Workspaces