No, generation is easier.
Take a random permutation along both axes of
|."0 1~ >:i.9
and then erase numbers as long as they’re derivable
by what remains.

Am 14.10.21 um 04:19 schrieb Devon McCormick:
I just put up this page from a past NYCJUG meeting where we talked about
sudoku - https://code.jsoftware.com/wiki/NYCJUG/2012-11-13#Show-and-Tell -
and it only took me ten years!
Perhaps a harder puzzle is to generate sudoku.

On Wed, Oct 13, 2021 at 7:59 PM Hauke Rehr <hauke.r...@uni-jena.de> wrote:

but since N2, N1 and N0 are boxed,
you need (N2;N1;<N0) rather than (N2;N1;N0)
or, even simpler since they’re already atomic
boxes (only one item, empty shape):

  > is&.>/ (N2,N1,N0) (<@mn@:{)"0 _ g

you may even get rid of the "0 _
(but read the vocabulary page for { carfully)


Am 14.10.21 um 01:37 schrieb Hauke Rehr:
if I now understand your first question correctly,
you want to learn how to shorten a phrase with
much repetitive structure

first of all, you can define 'is' this way
is =: e. # [


your expression looks like
(v N2{g) is (v N1{g) is (v N0{g)
with v equal to mn etc.

if you want to factor out g, you can say
((N2 v@:{ ]) is (N1 v@:{ ]) is (N0 v@:{ ])) g

… and if you define
MN =: mn@:{
you get
((N2 MN ]) is (N1 MN ]) is (N0 MN ])) g

if what I wrote for a1, a2 and a3 is correct,
you may then do

  > is&.>/ ((N2 MN ]);(N1 MN ]);(N0 MN ])) g

which may be further simplified to

  > is&.>/ (N2;N1;N0) (MN&.>)"0 _ g

and we may substitute back

  > is&.>/ (N2;N1;N0) (mn@:{&.>)"0 _ g

I hope this works; and maybe someone wants to
comment on different ways to reduce repetitive
expressions.


But if your main concern was solving the task
of writing a sudoku solver, take a look at the
wiki page Ric pointed to.


Am 14.10.21 um 01:04 schrieb Hauke Rehr:
Concerning the first question:

try adding ] where g used to be,
or inserting an & before the {
(but I didn’t study your code
enough to /know/ this will work)

Am 14.10.21 um 00:52 schrieb 'Viktor Grigorov' via Programming:
Hello,

Recently I saw an article in lobste.rs
(https://www.hillelwayne.com/post/sudoku/) about sudoku solving, and
though t, "it'd be nice to try it J". (Didn't even bother reading it,
but later glancing at it found the author had used J in the end. :D)

I reshape a list of integers of length 81 with blanks being 0s,
row-wise, from top, going left-to-right; into a 4-cube of length 3;
and define 3 auxiliary verbs.

g=:3 3 3 3 $ ...
q=:i.3NB. has missing
hm=:0&=@(<./)@,
NB. intersection
is=:([e.])#[
NB. missing numbers
mn=:13 :'((-.((>:@i.9)e.,y))#(>:@i.9))'

Although one usually solves sudoku (I think) by thinking of
exclusions, as the article's first paragraph or so suggested. I
wanted to find symmetries or something similar, thinking of it as a
higher dimmensional thing, hence the 4-cube. The constraints, or
symmtetries, or whatever they may be are the 9 rows, columns, and
faces each containing 1--9 once. My idea is to try each of the 81
cells until once with only one overlap is found, break, then repeat
until no change.

The sudoku given as an example in the english wikipedia article for
sudoku has an 'easy' example, wherein the center of the center
resolves to 5 using the intersection of the missing numbers of the 5.
row, 5. column, and 5. face; or within the tesseract:

(mn(<1;q;1;q){g)is(mn(<1;1;q;q){g)is(mn(<q;q;1;1){g)
((mn(<1;q;1;q)&{)is(...)is(...))g NB. nope

Taking out g and binding the from doesn't work, giving me just 1--9.
Trying  to take out the coordinates doesn't fair well for me either.

How can one shorten the former expression using bindings?

My second question regards is/: if I define a1, a2, a3 as missing
numbers in the row, column, face of some cell, why does is/ a1  a2 a3
give a syntax error, when a1 is a2 is a3 doesn't?


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
----------------------
mail written using NEO
neo-layout.org

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
----------------------
mail written using NEO
neo-layout.org

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to