Is my implementation of happy number OK

Jon Ribbens jon+usenet at unequivocal.co.uk
Thu Apr 30 19:31:45 EDT 2015


On 2015-04-30, Dave Angel <davea at davea.name> wrote:
> Finally, I did some testing on Jon Ribben's version.  His was 
> substantially faster for smaller sets, and about the same for 10*7.  So 
> it's likely it'll be slower than yours and mine for 10**8.

You know what they say about assumptions. Actually, my version is six
times faster for 10**8 (running under Python 3.4).

> But the real reason I didn't like it was it produced a much larger
> set of happy_numbers, which could clog memory a lot sooner.  For
> 10**7 items, I had 3250 happy members, and 19630 unhappy.  And Jon
> had 1418854 happy members.

Er, what? You're complaining that mine is less efficient by not
producing the wrong output?



More information about the Python-list mailing list