My apologies if I've missed it, but has anyone posted how long the vector
approach takes to find the longest chain under 1000000 and the highest
number in that chain?
The answers are - longest chain: 837799 ; steps: 524 ; biggest number in
chain: 2974984576

I am also not completely clear on the verdict re M.
It's a very simple functionality usually, for any monadic function, already
computed results are stored in a lookup table, which is checked on every
invocation to avoid recomputation.  Even if there is something wrong with
the builtin adverb M. (is there?) it shouldn't be too difficult to write
another one from scratch.

In any case, it should be doable, and usable for anyone who does not want
to resort to the vector approach, which I still find somewhat inscrutable.
I've even done the recursive one in Javascript (as well as C++, < 1") for
crying out loud, should J really be putting us through such hoops?




On 6 August 2014 06:51, mvillarino <[email protected]> wrote:

> > Roger's version wins by a long shot (2.2 vs 2.1 vs 1.7).  It invokes
> fewer
> > verbs.  The interesting thing is that it's collatzv that runs faster not
> > the code that follows - meaning that the interpreter is smart enough to
> use
> > integer arithmetic before we even get to *<.* ?!?
>
> In Roger's definition of cnv, it uses an auxiliary with a helpful
> name: "m", containing a <. which, if my tests are right, is unneeded
> because of the same reason.
> ----------------------------------------------------------------------
> 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