sudoku: update for iota
parent
cd80dfe667
commit
02e920b5ef
|
@ -0,0 +1,4 @@
|
||||||
|
IN: sudoku.tests
|
||||||
|
USING: tools.test sudoku ;
|
||||||
|
|
||||||
|
[ ] [ sudoku-demo ] unit-test
|
|
@ -19,7 +19,7 @@ SYMBOL: board
|
||||||
|
|
||||||
: box-any? ( n x y -- ? )
|
: box-any? ( n x y -- ? )
|
||||||
[ 3 /i 3 * ] bi@
|
[ 3 /i 3 * ] bi@
|
||||||
9 [ [ 3dup ] dip cell-any? ] any?
|
9 iota [ [ 3dup ] dip cell-any? ] any?
|
||||||
[ 3drop ] dip ;
|
[ 3drop ] dip ;
|
||||||
|
|
||||||
DEFER: search
|
DEFER: search
|
||||||
|
@ -35,7 +35,7 @@ DEFER: search
|
||||||
[ assume ]
|
[ assume ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
: solve ( x y -- ) 9 [ 1 + 2over attempt ] each 2drop ;
|
: solve ( x y -- ) 9 [ 1 + 2over attempt ] each-integer 2drop ;
|
||||||
|
|
||||||
: board. ( board -- )
|
: board. ( board -- )
|
||||||
standard-table-style [
|
standard-table-style [
|
||||||
|
@ -52,7 +52,7 @@ DEFER: search
|
||||||
] each
|
] each
|
||||||
] with-row
|
] with-row
|
||||||
] each
|
] each
|
||||||
] tabular-output ;
|
] tabular-output nl ;
|
||||||
|
|
||||||
: solution. ( -- )
|
: solution. ( -- )
|
||||||
solutions inc "Solution:" print board get board. ;
|
solutions inc "Solution:" print board get board. ;
|
||||||
|
|
Loading…
Reference in New Issue