telz=: 3 :0
zx=. <.-:y
zm=. 1+<.y%3
+/>.-:(1&{-y-+/) (,:<:)zm+i.1+zx-zm
)

   telz&> 54+i.7
61 56 65 61 70 65 75

One step further, based on pattern analyzing, I have:

cnt3 =: [:+/+/\@((0&=@],|.&1 2@]$~[:-/0 1+<.@%&2 3@[)3&|)

   cnt3&>4+i.15
0 0 1 0 1 1 2 1 3 2 4 3 5 4 7


For those interested in sequences :-)

... and (of course) this sequence can be found in OEIS http://oeis.org/A005044
with an offset of _3

With a translation of one of the PARI programs shown there:

   <.@(0.5+%&12@*:-<.@%&4@*:@<.@-:)&> _3 + 54+i.6
61 56 65 61 70 65

   NB. compared to

   cnt3&>54+i.6
61 56 65 61 70 65


--
Met vriendelijke groet,
@@i = Arie Groeneveld

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to