On Mon, Dec 4, 2017 at 9:46 PM, Brian Schott <[email protected]> wrote:
> This is fascinating and compact code for part 2.
> You are using (;.3} tesselation shards very cleverly.
> I have  not quite figured out your method, and am mostly wondering how
> you are forcing the order of tesselation steps to conform to the spiral
> sequence in the array.

What I'm doing is treating this sort of like the fibonacci sequence.
Except instead of each successive item being the sum of the previous
two items in the list, I am using lists of indices each step of the
way (indicating the positions of the items to be summed).

And those indices are the indices which are adjacent to and less than
the corresponding spiral index in the spiral. I keep these in boxes
because I have to deal with varying numbers of them (typically 2 or 3
indices). (Though, in retrospect, I think I could have done
it with a flat array - if that matters...)

It's actually a bit sloppy out at the end of the sequence, because of
how tessellation works, but that doesn't matter because I never get
that far. (In retrospect, I might have been able to use the more
accurate ;._3 tessellation, but since that doesn't really matter I've
left it how it is.)

Here's the content of the first nine boxes, right before I reverse
them (these indices are not in sorted order because of the layout of
the spiral, but that's just another thing that doesn't really matter):

1
0
1 0
1 0 2
0 3
0 3 4
0 5
6 1 0 5
7 1 0

Let's call those boxes S. Here's grinding through those first 9:

   ;(],+/@:{)L:0/|.9{.S
1 1 2 4 5 10 11 23 25

Now, if I was smart, instead of using that expression, I'd get rid of
the rightmost insert (/) and replace it with something like a while
loop and I'd stop when I get a large enough of a result...

I hope this makes sense,

-- 
Raul

P.S. I apologize for the debugging issue. It would be nice if the
debugger could be smarter about such things, but it's not - and I know
that, but went ahead and phrased my code this way anyways.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to