sudoku: update for iota

db4
Slava Pestov 2010-01-15 06:22:12 +13:00
parent cd80dfe667
commit 02e920b5ef
2 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1,4 @@
IN: sudoku.tests
USING: tools.test sudoku ;
[ ] [ sudoku-demo ] unit-test

View File

@ -19,7 +19,7 @@ SYMBOL: board
: box-any? ( n x y -- ? )
[ 3 /i 3 * ] bi@
9 [ [ 3dup ] dip cell-any? ] any?
9 iota [ [ 3dup ] dip cell-any? ] any?
[ 3drop ] dip ;
DEFER: search
@ -35,7 +35,7 @@ DEFER: search
[ assume ]
} cond ;
: solve ( x y -- ) 9 [ 1 + 2over attempt ] each 2drop ;
: solve ( x y -- ) 9 [ 1 + 2over attempt ] each-integer 2drop ;
: board. ( board -- )
standard-table-style [
@ -52,7 +52,7 @@ DEFER: search
] each
] with-row
] each
] tabular-output ;
] tabular-output nl ;
: solution. ( -- )
solutions inc "Solution:" print board get board. ;