Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,5 +1,5 @@
# Solves Sudoku using brute force.
# Experimental!
# Solves Sudoku using built-in ''path'' function.
S ← [[8 5 0 0 0 2 4 0 0]
[7 2 0 0 0 0 0 0 9]
[0 0 4 0 0 0 0 0 0]
@ -9,18 +9,18 @@ S ← [[8 5 0 0 0 2 4 0 0]
[0 0 0 0 8 0 0 7 0]
[0 1 7 0 0 0 0 0 0]
[0 0 0 0 3 6 0 4 0]]
Ps ← ⊞⊟.⇡9
Boxes ← ↯∞_9_2 ⊡⊞⊂.0_3_6 ◫3_3Ps
Nines ← ⊂Boxes⊂⟜(⮌1_0)Ps # 27 lists of pos's: one per row, col, box.
IsIn ← ☇1▽:⟜≡(∊:)Nines ¤ # (pos) -> pos's of all peers for a pos.
Peers ← ⊞(IsIn ⊟).⇡9 # For each pos, the pos of every peer (by row, col, box)
Posns ← ⊞⊟.⇡9
Units ← ↯∞_9_2 ⊡⊞⊂.0_3_6 ⧈∘3_3Posns # rows, columns, and boxes.
Nines ← ⊂Units⊂⟜(⤸1_0)Posns # 27 lists of pos's: one per row, col, box.
IsIn ← ♭₂▽:⟜≡(˜∊:)Nines ¤ # (pos) -> pos's of all peers for a pos.
Peers ← ⊞(IsIn ⊟).⇡9 # For each pos, the pos of every peer (by row, col, box)
Free ← ▽:⟜(¬∊)+1⇡9◴▽⊸(>0)⊡⊡:Peers # Free values at pos (pos board) -> [n]
Free ← ▽:⟜(¬˜∊)+1⇡9◴▽⊸(>0)⊡⊡:Peers # Free values at pos (pos board) -> [n]
Next ← (
=/↧.≡(⧻Free) ⊙¤,,⊚=0. # Find most constrained pos.
Free,,⊙◌⊢▽⊙. # Get free values at pos.
≡(⍜⊡⋅∘)λBCa # Generate node for each.
⊢▽=/↧.≡(⧻Free)⊙¤⊚=0. # Find most constrained emptypos.
◠Free⊙°¤ # Get free values at pos.
≡(⍜⊡⋅∘)∩¤ # Generate next node using each.
)
End ← =0/+/+=0
astar(⍣Next⋅[]|0|End)S
↙¯1°□⊢⊙◌
⊣⊢path(⍣Next⋅[]|End)S