Talk:Summarize and say sequence: Difference between revisions

Line 44:
:::::: Er, don't take that example so literally. Suppose the question is, "of numbers 24132231 and 14233221, which has the longest sequence", for example (and no, don't take this example too literally, either. I'm just saying, only caching sorted string of each permutation has its problems.) --[[User:Ledrug|Ledrug]] 21:05, 25 August 2011 (UTC)
::::::: Ok... but as a general rule, overgeneralizing code can introduces complexity and inefficiency. --[[User:Rdm|Rdm]] 21:13, 25 August 2011 (UTC)
:::::::: That was what I was griping about... actually come to think of it, now I remember what was bugging me: the C code does <lang>function seqlen(n):
if n in cache then: return cache[n]
else: return 1 + seqlen(next(n))</lang>
:::::::: Before this I had <code>if sorted(n) in cache then: return cache[sorted(n)]</code>, which can lead to incorrect results if a sequence ends in A->B->B, where <code>sorted(A)</code> is the same as <code>sorted(B)</code>. It so happens that it doesn't affect this task, but this consideration is not exactly overgeneralization. --[[User:Ledrug|Ledrug]] 21:26, 25 August 2011 (UTC)
Anonymous user