Prasad Ravi had a good point -- We should verify that our code works before posting it.
Two suggestions: There will be times, as Lou Pagoda points out, that this is not realistic.
In that case, we simply state that the code has not been tested,
although the solution we had in mind looks something like...

A discussion group is a free-for-all.
Persons ask for advice and solutions at no cost, and sometimes they get what they pay for.

There are many times when I think I had an answer, but should have asked more questions first.
So the answer provided doesn't always fit the question the first time around.
 
The Pareto Principle applies to discussion groups: 90% of the responses come from 10% (or less) of the members in that group.  If we want to encourage more responses, we should also avoid "poking people in the eye" with comments like:

"...the tone of the person making the mistake
   "Good answer.  But I use a little less code:"
   was not one of making a helpful suggestion as much as look at how good I am"

HTH
Rob Krajcik