Your input isn't the problem. $: can be a big source of innefficiency, as it has to keep all past results in memory.
timespacex 'v^:(20) 3 1 1 3 3 2 2 1 1 3' 0.0475805 6.57267e6 timespacex ',@((# , {.);.1~ (~: |.!.0))^:20 ] 3 1 1 3 3 2 2 1 1 3' 0.00126528 152192 crashes for me at v^:24. the string gets very long, and you are calling $:@tail 100k times+ on the list at around 20 iterations. The combination with $: is deadly. ________________________________ From: Brian Schott <schott.br...@gmail.com> To: Programming forum <programm...@jsoftware.com> Sent: Saturday, December 12, 2015 8:57 PM Subject: Re: [Jprogramming] advent 10 My attempt fails with a stack error after about power of 25, so I cannot use it to solve day 10, really. The code below can be used as follows, but 40 cannot replace 25. I tried M. but with no effect. Any other recommendations would be appreciated. NB. v ^: (25) 3 1 1 3 3 2 2 1 1 3 Notice that I elected to use 3 1 1 3 3 2 2 1 1 3 to start and I noticed others some chose to use instead of 1 1 1 3 2 2 2 1 1 3 (I think Henry has a typo in his version, btw). I don't understand why that choice was made. m66 =: 1 ,~ 2 ~:/\ ] headNo =: (1 + (i.&1))@m66 head =: headNo{.] tail =: headNo}.] next =: headNo , ({.@head) v =: ]`(1,])`($:@:tail,~next)@.(2<.#) On Thu, Dec 10, 2015 at 4:29 PM, Henry Rich <henryhr...@gmail.com> wrote: > We all had the same solution. My version is > > # ,@((# , {.);.1~ (~: |.!.0))^:40 "."0 '1113122113' > > Henry Rich > > > -- (B=) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm