"As is the case in so much of life, context is everything. Judgement has to enter into it. Personally, I'm inclined to run the risk of helping the lazy to avoid the risk of quelching someone's drive to learn."
I agree. It's sometimes tough to draw the line between those looking for easy answers and those who are actually trying to learn.
I think the thing to do is when something looks like homework, point them to resources instead of just handing them code. If they're not willing to do the work to figure out at least part of the equation, they don't deserve the answer. When someone's made the effort of writing and posting some code (or at least formulating an intelligent question that shows that the individual has at least tried to tackle the problem) and saying "This doesn't work - and I can't figure out why", then I think it's entirely appropriate to help them by solving their problem - and provide an explanation as to why that works.
There's more than one way to screw it up...