Talk:Hofstadter Q sequence

From Rosetta Code
Revision as of 16:25, 28 October 2011 by rosettacode>Ledrug (→‎Recursion limit issue: and it wasn't difficult anyway)

Python non-recursive solution

Thanks Ledrug. I had a brain freeze on removing the recursion and blundered on with the accommodation of the recursion limit solution. --Paddy3118 18:34, 23 October 2011 (UTC)

Recursion limit issue

As Ledrug pointed out wrt. to my Dart solution with cache, there is a problem when calling the function with a large number first (e.g. q(100000)) since the cache is filled recursively counting from n to 2 if it is empty (happens with the Java solution for example). This doesn't occur in the calculations necessary to solve the tasks since this way the cache is filled ascending. Maybe the task description should be changed whether it is required to accommodate this. --AlexLehm 09:53, 28 October 2011 (UTC)

I updated the task. The recursive Python solution has a similar issue but with Pythons recursion limit being set at only 1000 by default. The extra credit solution gets around this.
I think that solutions should address such issues in an extendable way if at all possible (not hard-coding something that works just for this tasks value of n). --Paddy3118 14:38, 28 October 2011 (UTC)
My view is: since examples all define Q as a function, it should try its best to ensure the return values don't depend on call history, because that's what one tends to expect. It's best not to (unnecessarily) surprise people. --Ledrug 16:25, 28 October 2011 (UTC)