I just solved this and posted a come-on for my usual rant about these
sort of problems: what was the total time to reach a solution, coding plus
execution time?

As is common in these sort of articles, there are multiple iterations to
solving
the problem but the main concern at each iteration is CPU time.  This
emphasis
frequently puts J at an apparent disadvantage.  We should not let the
dialogue
continue to be framed in terms of CPU time to the neglect of total time to
solution.

On 4/8/07, Tracy Harms <[EMAIL PROTECTED]> wrote:

I've been working on the puzzle from Dr. Dobbs that
Randy MacDonald announced here:
http://www.jsoftware.com/pipermail/chat/2007-April/000467.html

I'm still not ready for full-fledged spoilers, but I
am asking for help getting past one particular error
condition.  The problem is that an index error is
reported when I try to load the script, but it seems
fine when I run it in the J console.

My approach to solving the puzzle is:

reportstates same_chars same_tallies 4 comb 50

I've only developed this as deep as verb same_tallies,
which is:

same_tallies =: ((tally_leftpairs = tally_rightpairs)
y.) # y.

Here are the component verbs:

tally_leftpairs  =: 3 : '+/"1 (0 1 {"1 ((i.#y.) { y.))
{ tallies'
tally_rightpairs =: 3 : '+/"1 (2 3 {"1 ((i.#y.) { y.))
{ tallies'

Now I'll show testing from a J session, ending with an
error on attempt to load the same verb that functioned
perfectly when entered in the console:

   twocomb =: 0 1 11 14 ,: 4 5 6 20
   twocomb
0 1 11 14
4 5  6 20
   twocomb { states
+----------+--------+-----------+-------------+
|Alabama   |Alaska  |Idaho      |Iowa         |
+----------+--------+-----------+-------------+
|California|Colorado|Connecticut|Massachusetts|
+----------+--------+-----------+-------------+
   twocomb { tallies
7 6  5  4
10 8 11 13
   (0 1 {"1 ((i.#twocomb) { twocomb)) { tallies
7 6
10 8
   (2 3 {"1 ((i.#twocomb) { twocomb)) { tallies
5  4
11 13
   +/"1 (0 1 {"1 ((i.#twocomb) { twocomb)) { tallies
13 18
   +/"1 (2 3 {"1 ((i.#twocomb) { twocomb)) { tallies
9 24
   load 'c:\j504\user\miscellany\statespzl2.ijs'
|index error: tally_rightpairs
|   +/"1(2 3    {"1((i.#y.){y.)){tallies

No error was signaled for the line before it, which
differed only in the values of the pairing noun:

tally_leftpairs  =: 3 : '+/"1 (0 1 {"1 ((i.#y.) { y.))
{ tallies'
tally_rightpairs =: 3 : '+/"1 (2 3 {"1 ((i.#y.) { y.))
{ tallies'

I'm at a loss as to what needs to be fixed, here.

--
Tracy B. Harms

     It is the central thesis of this book that the descriptive
     and analytic power of an adequate programming language amply
     repays the considerable effort required for its mastery.
                                Kenneth E. Iverson
                                A Programming Language, 1962




____________________________________________________________________________________
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to