On 12/4/05, James Edward Gray II <james / grayproductions.net> wrote:
>
> It's cheating to get correct answers quickly?  ;)

Well something had to generate those answers in the first place, and
for that I'd take my, Rob, or Edward's solution any day.

> I haven't compared the Array in question with the posted sequences.
> Perhaps it's not very complete.  Let me ask you this though, since
> we're talking about this:  Which is easier to debug, the sequence
> list or a broken calculation solution?

Well I certainly debugged mine by looking at the pre-existing list,
which was useful. But the fact that his list was missing things really
caused me pause, because if someone depended on that list to be
accurate, they would be in trouble.

> Didn't the solution also brute force answers when it left its list of
> known numbers?

Yes but his brute-force algorithm is extremely slow, and his list is wrong.

> One last question:  How well does your presumably fast solution do
> when it goes beyond the listed sequence?  Does it still find lots of
> answers, quickly?

Of the three fastest solutions so far (Edward's, Rob's and mine), all
continue to generate answers at a similar rate, consistently. For
example, to generate up to 100000, the time was 16.687, 17.281 and
18.469 seconds (in the order listed above, i.e. mine is slowest.)
Since there are 204 weird numbers between 0 and 100000, each algorithm
generates about 11-12 per second.

> I'm really not trying to be mean here and I apologize if I'm coming
> off that way.

Well I've probably come off as mean to Hampton, and I don't really
want to come off that way either. But it does rub me the wrong way to
have someone call their solution fast when the solution is WRONG.

> I think what Hampton hit on is a simple cache optimization.  It's
> fast and very effective.  I don't think we should be so quick to toss
> it out as a viable approach...

His caching optimization is certainly a good idea (and fairly
obvious), though it would be better if it actually generated the cache
and reused it so that subsequent runs got faster. I may code up
something like this.

Ryan