Mine's similar:

steps=:3 :0
  bounds=. _1+0,#y
  cnt=. 1+ndx=. 0
  while. 1=bounds I. nxt=. ndx+off=. ndx{y do.
    y=. (1+off) ndx} y
    ndx=. nxt
    cnt=. 1+cnt
  end.
)

But part 2 was only required another 7 characters, so there's that
(though it also took over 70 times as many steps to complete.)

That said, I should perhaps note that my leaderboard score is 0 - I'm
waiting plenty of time before trying these things.

-- 
Raul

On Tue, Dec 5, 2017 at 5:05 PM, Ric Sherlock <[email protected]> wrote:
> Did anyone come up with a nice Jish solution for this?
>
> Mine (see below) ended up being very scalar.
>
>
>
>
>
>
>
>
>
>
>
>
>
> countJumps=: 3 :0
>
>   count=. idx=. 0
>
>   offsets=. y
>
>   while. (0 <: idx) *. (idx < #offsets) do.
>
>     count=. count + 1
>
>     idx_new=. idx ([ + {) offsets
>
>     offsets=. idx (1 + {)`[`]} offsets
>
>     idx=. idx_new
>
>   end.
>
> count;idx;offsets
>
> )
>
>
>    countJumps 0 3 0 1 _3
>
> 5
> ----------------------------------------------------------------------
> 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