Also, you appear to rely on very specific solutions. In the nested-parens example, you want to change the last line to “return depth == 0”. I want to add the line “if depth > 0 return False”. These solutions are clearly equivalent. How then am I to guess which one you want?
Ok, that’s a fair cop. I don’t usually code in Python and could well have got that wrong. Still, if that were the problem then the desired solution should have been a correction of my syntax error, not a change from two returns to one; so I stand by my criticism that the database is too small.
Also, you appear to rely on very specific solutions. In the nested-parens example, you want to change the last line to “return depth == 0”. I want to add the line “if depth > 0 return False”. These solutions are clearly equivalent. How then am I to guess which one you want?
We have a database of multiple “acceptably good solutions” to each problem.
It’s clearly not big enough. :)
If you didn’t put a colon between 0 and return, it’s invalid syntax.
Ok, that’s a fair cop. I don’t usually code in Python and could well have got that wrong. Still, if that were the problem then the desired solution should have been a correction of my syntax error, not a change from two returns to one; so I stand by my criticism that the database is too small.
Isn’t the “return depth == 0” solution simpler and so superior? (That’s a question, I don’t actually know Python that well.)
A point of taste. My solution makes it explicit what is being checked for: Unclosed parens.