My reference to Perl's output was of the solutions printed on the count
lines such as this:

1: 2 27 28
2: 3 26 28
3: 4 25 28
.....

60: 17 19 21
61: 18 19 20
Total 61

Raul, thank you so much for your other pointers on inspecting the arrays. I
will have two more days after work going over all of that. It's amazing how
working through this seemingly simple problem with your help has taught me
more about J than the hours I spent just doing single bits from the J
dictionary. What would be the best J book to go through the vocabulary in
problem sets such as this? Rosetta code? J for C programmers?

My son said that one of the students arrived at the correct answer of 61
without a computer. I can't believe this given the time it would require to
go through the answer space via pencil and paper (28^3). Is there a closed
form solution, or algebraic solution?

Good night, it's almost 3 am here in Macau.

Thanks,

Rob



On Mon, May 27, 2013 at 2:19 AM, Raul Miller <[email protected]> wrote:

> On Sun, May 26, 2013 at 2:01 PM, Robert Herman <[email protected]>
> wrote:
> > I have worked through the solution arrived at by a few of you to better
> > learn J, namely this one:
> >
> > +/,(57=x+/y+/z)*x</y*y</z
> >
> > In order to fully understand the way the matrix operations are carried
> out,
> > I minimized the answer space by making P = 13, and worked through the
> > output (not shown for brevity's sake) of the following input lines I
> placed
> > in a project file (learning the IDE with this problem too):
> >
> > P =: 13
> > x =: >:i.4
> > y =: >:x
> > z =: >:y
> >
> > 3 4 $ x,y,z
> >
> > (13=x+/y+/z)*x</y*y</z
> > +/,(13=x+/y+/z)*x</y*y</z
> >
> > +/,((13=[+/+/)*[</]*</)~i.7
>
> Since this is a rank 3 bit array, we can ask J to display it more
> compactly.
>
>    <"2 '.*'{~((13=[+/+/)*[</]*</)~i.7
>
> We can also use this prefix to inspect some of the intermediate results:
>    <"2 '.*'{~([</]*</)~i.7
>    <"2 '.*'{~(</)~i.7
>
> That said, some interemdiate results are not bit arrays and are
> perhaps best inspected directly:
>    (]*</)~i.7
>
>
> > Anyway, I was tempted to try and make the J program look like the Perl
> > oneby using
> > for. but I realized I was lapsing into old habits. My minimal programming
> > experience is all with imperative languages or some Lisp too. My next
> > question is how do you get the J program to print the solutions as in the
> > Perl program?
>
> That's an open-ended question, since "as in" has a contextual and case
> specific meaning.
>
> Personally, I usually try and understand intermediate results (usually
> there is only one and I can just extract an expression which computes
> it and see what it does with sample data.
>
> > In my 3 x 4 matrices of the reduced problem set, I could see
> > how the 1's in the solution selection matrix set related to the original
> 3
> > x 4 matrix of x, y and z rows. Without re-writing it, is there a way to
> > index the solution?
>
> I am not sure what you mean by this.
>
> I mean, of course you can index the solution, but the solution has
> only a single number.  You can also rewrite the expression which
> creates that solution and index from those results. But I feel like I
> am not understanding your question.
>
> > One question that is on my mind is the tacit vs. explicit style. I am in
> > love with the way you all distill the solution down to a tacit one-liner,
> > just as a maths formula is simplified, however, I am starting to think
> that
> > if and when I revisit this problem in the future, it will take a bit of
> > jarring to read it, translate it if you will. I am guessing for. loops
> are
> > very expensive cycle-wise and it would be just as easy to make words for
> > phrases if I wish to preserve future readability. I am getting addicted
> to
> > the fast way of working in the J environment, and I am grateful to all
> on this
> > list for sharing their wisdom.
>
> I think that any time we delve into some area of computation that
> leaving and coming back after an extended absence can leave us in a
> jarring situation where we need to reacquaint ourselves with the
> original topic. I do not know of any general cure for this, finding
> good names for things, and good examples, can be fruitful.
>
> Thanks,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to