Recently we had the question "Project Euler Problem #12 - Highly divisible triangular number"
It was closed as the OP included how to use the function with the function's code.
The function works, and so I don't think it should be closed as broken because of an
NameErrorin the example usage, because
numisn't declared. We allow this exception in other questions, even if half the program up for review is filled with them, not example input.
We shouldn't guess input to the function:
@Peilonrayz, which is what? The problem which this is attempting to solve is quite small and specific, so the code which solves it should run standalone without requiring the user to guess a value for an undocumented parameter. – Peter Taylor Apr 25 at 8:38
Another user in chat also held this view.
Because it takes a while on large inputs:
-1 from me because the Code does not solve the problem. I was not able to find the result. for small values of num the program finishes without printing a result and for larger numthe program hangs up without printing a result. – miracle173 Apr 26 at 16:18
I don't think anyone's arguing for or against the first reason for closure. And the third has already been addressed. What should our views on the second be?
Should we close questions for naive implementations implementing limits, when they're not needed?
If you replace
for n in range(1,num) with
for n in itertools.count(1), then there would be no problem. Or if a user entered
float('inf') if they knew about it and if it worked with
range. They're a novice and doing the next best thing they know of.