JK = June Kim, DB = me
JK> ((8$0) mod r) length 4 6,:0 6
JK> NB. result is 5 3
DB> c length r
DB> _ 2 0
Ah, I see my result differs from yours. I conclude you're allowed to climb
back up the tree? OK:
dist =: 1 + dist@:(, |."1) f.
c length r
5 3 1
And see? I knew there was a reason to mark the diagonal specially:
dist r
0 1 1 2 2 2 3 2
1 0 2 3 1 3 4 3
1 2 0 1 3 1 2 1
2 3 1 0 4 2 3 2
2 1 3 4 0 4 5 4
2 3 1 2 4 0 1 2
3 4 2 3 5 1 0 3
2 3 1 2 4 2 3 0
-Dan
PS: Complete script:
CM =: (#. e.~ [: i. [ , [)~ 1 + >./@:,
closure =: ([ +. +./ .*.)^:a:~
ln =: [EMAIL PROTECTED]
distu =: [: ln 0 |: closure@:CM@:(, |."1)
crct =: 1 + ] * _1 ^ =@:i.@:$
dist =: [EMAIL PROTECTED]
length =: <"1@:[ { dist@:]
r =: _2 ]\ 0 2 0 1 2 3 2 5 2 7 5 6 1 4
c =: _2 ]\ 4 6 0 6 2 3
c length r
5 3 1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm