Talk:Happy numbers: Difference between revisions

Content added Content deleted
(→‎On caching (and laziness): slight fix: It's not really the first part, because you don't actually do it; but it can still be seen as "half" of the step, so the argument remains)
(→‎On caching (and laziness): no permutations: a single "bunch of data" is enough)
Line 4: Line 4:
: You don't need ''any'' caching (see the alternative C++ version I've just added). Of course you'll do more calculations anyway, so this is still a time/space tradeof.
: You don't need ''any'' caching (see the alternative C++ version I've just added). Of course you'll do more calculations anyway, so this is still a time/space tradeof.
: Also note that your "normal form" is "half" of the iteration step. Of course your cache is more effective if you also add the second step (because, after all, numbers which have a different normal form may still have the same next number (e.g. both 1111 and 2 have 4 as next value). But that's the same as using the original cache, but not caching in the first iteration. So the savings with your optimized cache are probably negligible. --[[User:Ce|Ce]] 07:20, 7 May 2009 (UTC)
: Also note that your "normal form" is "half" of the iteration step. Of course your cache is more effective if you also add the second step (because, after all, numbers which have a different normal form may still have the same next number (e.g. both 1111 and 2 have 4 as next value). But that's the same as using the original cache, but not caching in the first iteration. So the savings with your optimized cache are probably negligible. --[[User:Ce|Ce]] 07:20, 7 May 2009 (UTC)

:: We don't need to store the permutations. Since, for the final computation, what really matters is how many of every digits there are...; e.g. 910: I don't need to store 190, 910, 109 (and eventually 019, which indeed with the "Bag" technics is considered different from 19); it is enough I say that a number containing one 0, one 1 and one 9 is happy. --[[User:ShinTakezou|ShinTakezou]] 10:50, 7 May 2009 (UTC)