As I am reading through this, here are some thoughts. First, here are some alternate definitions I am noticing that might be worthwhile.
xor=: ~:/ nOnes=: = i. dToSudoku=: ,~@%:@# $ (1 = +/"1) * (1 + {.@I."1) You could replace = with e.~ in nOnes if you wanted to respect a variable length X Also, I think I might write sudokuToArcs something like this: require 'stats' sudokuToArcs=: 3 :0 N=. #y B=. %: N T=. *: N pairs=. [: ,/ (2 comb N)&{/.&(i.T) row=. N#i.N col=. T$i.N box=. , (] +/ B * ] ) B # B $ i. B 1,.~ ~. /:~ (pairs row),(pairs col),pairs box ) The line 9 {. D NB. show the domains for the first row of the sudoku. does not make sense to me. I started to write a variant on revise, but I ran into two issues: 1. You are modifying the value D 2. The test values are not illustrative This means that the intent of the code is not apparent to me, and any suggestions I make would likely be irrelevant. -- Raul On Thu, Nov 22, 2012 at 12:57 AM, Michal D. <michal.dobrog...@gmail.com> wrote: > Hi All, > > The time has come for a more minimal version of Arc Consistency that works > over a list of arcs and does away with an adjacency matrix. The main > change is that revDom now modifies both domains at the same time. Along > with this is a random sudoku generator. It's setup to generate 4x4 sudokus > though you can easily generate 9x9 sudokus as well. > > NOTE: arc consistency, in general, will not be able to solve a sudoku > unless it's easy. What it allows is decreasing the search space during > back tracking search. > > http://pastebin.com/JdECdEbK > > Cheers, > > Mike > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm