I think you're going to need to dive some more into the math of the permutations here.
I have not done that myself. However, I suspect that you would need four kinds of "constraint rectangles" here, to fully constrain the possibilities using Hui's approach. But Sudoku only provides three (rows, columns, blocks). Specifically, I think R needs to have shape 64 16, instead of 48 16. That said, this is just a hunch - I haven't analyzed this in any depth. Good luck, -- Raul On Sat, Jun 18, 2022 at 11:14 AM Brian Schott <schott.br...@gmail.com> wrote: > > I have been trying to adapt Roger Hui's sudoku solver > https://code.jsoftware.com/wiki/Essays/Sudoku to a 4x4 grid from his 3x3 > grid. I actually do not want such an automatic solution, and prefer a > solution which helps a human with some of the tedium, but in the meantime, > I think I would like an automatic solution as well. > > My problem seems to be that my adaptation does not screen adequately for > multiple identical "candidates". By that I mean in the following example, > for example, the "candidate" 3 appears three times, (by coincidence), as a > "solution" produced by the repeated application of the verb 'f', and in > particular, here, in the second update of the grid. To see what I mean, > execute the following commands on the attached script. > > load'~user/sudoku16forum.txt' > 9!:7'+++++++++|-' > f=: + (ac >. ar)@free NB. one step of assign > $,.see t=: f^:a: x NB. forced moves leading from grid x > 3{.see diff t > > In particular, look at the following result which shows 3 boxes (which I > hope are not wrapped by your email client, but if it is wrapped, you might > just look at 1 2&{ instead of 3&{. ). > In the third box, focus on the bottom righthand 4x4 region which contains > the characters E330 and '.'s . In that region itself there are two 3's, > which should not happen. But in addition each of those 3's collide with > external 3's in their own row or column, but outside the 4x4 region we are > focusing on. [I have attempted to produce the 3's below in *bold* type.] > I can't tell if this problem is a result of something I have done wrong in > my adaptation or if there is more coding required for 4x4 relative to 3x3, > or what. > > > > 3{.see diff t > +---------------------+---------------------+---------------------+ > |+----+----+----+----+|+----+----+----+----+|+----+----+----+----+| > ||5E..|2.1.|.F6.|039.|||....|....|....|...C|||....|....|....|....|| > ||....|5.D.|0E..|....|||....|....|....|.2..|||....|....|....|...1|| > ||.28E|6F3.|4...|B...|||....|...0|....|.D..|||....|....|....|....|| > ||.F.0|....|D...|.48.|||....|....|....|E...|||....|..A.|..2.|....|| > |+----+----+----+----+|+----+----+----+----+|+----+----+----+----+| > ||.5C.|.1.3|2...|A9BD|||....|....|..0E|....|||....|....|....|....|| > ||..A.|4...|1...|50..|||....|....|....|...2|||....|...6|....|..E.|| > ||1...|...E|..F2|...F|||....|....|9...|4C..|||....|....|....|..*3*.|| > ||.9.6|A.2.|..D.|7816|||..E.|....|....|....|||0...|....|...4|....|| > |+----+----+----+----+|+----+----+----+----+|+----+----+----+----+| > ||D1.8|...C|.49.|3.2.|||....|....|....|...0|||....|.E..|....|.6..|| > ||..09|..C.|....|.5..|||.6..|.A..|...D|....|||....|....|E...|....|| > ||73..|.2..|.A.6|..DE|||....|....|....|....|||....|..8.|....|....|| > ||AC..|.6B.|5..0|9..A|||..E.|....|....|....|||....|....|....|....|| > |+----+----+----+----+|+----+----+----+----+|+----+----+----+----+| > ||3...|.9..|..7.|D...|||.0..|...2|....|....|||....|....|....|.E..|| > ||.4..|.0.1|6DE9|2...|||....|....|....|....|||8.5.|*3*...|....|...*3*|| > ||....|E7.8|.0..|...7|||....|....|....|....|||..2.|....|....|..*3*.|| > ||EB.F|8..A|.2..|C1..|||..7.|....|3...|...9|||....|....|....|..0.|| > |+----+----+----+----+|+----+----+----+----+|+----+----+----+----+| > +---------------------+---------------------+---------------------+ > > > -- > (B=) <-----my sig > Brian Schott > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm