I've seen a question that asks for a review of a piece of code that solves a public coding challenge (linked in the question). The first comment just discloses the optimal solution without actually giving a proper code review. To me it seems counterproductive as this brings no value, only ruins the chance for the OP (and others) to find the solution him/herself.

Would it be appropriate to flag such comments/answers? I'd say it'd be much better to say something like "Note that there is an asymptotically better solution. For your particular implementation ..."

  • \$\begingroup\$ Shouldn't at least one solution be already publicly available in the question itself? If the solution is somehow revealed in the answers but not in the question, it sounds like the quest ought to be closed... \$\endgroup\$
    – nhgrif
    Commented Jun 28, 2015 at 13:19

3 Answers 3


There are two types of contest-questions posted to Code Review.

  1. contests/interviews which have been completed, or are not competitive
  2. contests which are active, and "current".

Code Review is a good place to post any code related to 'expired' or non-competitive contests.

When we are made aware of it, code for active/current contests are removed.

This has been discussed before: Online Contest Questions

and related to Project Euler: Project Euler Solutions

There is no meta discussion about 'active' contests, but I have responded to flags on about 3 or so occasions where posts for active contests have been removed, by me.

As some notes on "cheating":

  1. contests are used as a tool for learning, or evaluating progress/capability.
  2. if you cheat on a contest, you hurt yourself only, because any real contest, like an interview question, etc. will check your answer for plagiarism, etc.
  3. if you use code review to see how other people solve the problem, then that's exactly what code review can be good for, but you have to then understand why the solutions are better/work. Again, use it to learn.

Bottom line, we are just one part of the internet, people post code in all sorts of places.

Code Review is a logical place for it, if you post your own solution here you can learn just like any other post. If you find a solution here you can choose to learn from it too.


Related answer by 200_success.

Good answers should contain reviews. An alternative solution is only part of a review if it explains why it's implemented differently. Code dumps in the style of "This should do the trick: [code]" are no reviews.

Good answers often contain suggestions on how to do parts of the code better. This can include rewritten code. It should always include an explanation of why it's better, but yes, it's perfectly fine to include optimal code in the answer.

There are basically no rules for comments. As long as it's relevant, it's usually OK (unless it's non-constructive criticism, which should be flagged).

Basically, it's not acceptable in an answer but there is no rule against such comments.

Do note, people don't post their code here to find the optimal solution themselves. They post what their best try is and ask for review. By peers.


Would it be appropriate to flag such comments/answers?
I'd say it'd be much better to say something like "Note that there is an asymptotically better solution. For your particular implementation ..."

To answer this question directly...

No, it would not be appropriate to flag such comments/answers.

The only imaginable reason to flag a comment would be because the user is posting an answer as a comment. That's a pet peeve of mine, but honestly, I'm probably at least borderline guilty of this myself sometimes. Sometimes I know the right solution and can express that in a small number of words (usually with a link to a website that explains it), but I may not have the time or effort or understanding to actually review the code at the moment. And ultimately, there's actually nothing explicitly against answering questions in comments (answerers should just know they can earn no rep for that and their comment is susceptible to deletion far easier than an answer).

I can see no reason for flagging the answer. I can recommend down voting it. I'm not recommending down voting the answer though for the specific reason you've come to the meta, but for the reason that I recommend down voting any code-only answer. At Code Review, we want reviews. We don't just want someone to rewrite the code in the answer. We want to know why the alternative version proposed is better and what the specific problems with our original version was. Is the difference between the two pieces of code really nominal and purely up to personal preference as to which looks better (or there's some sort of tradeoff you have to decide between)? Down vote the answer not because it's a "spoiler" but because it's a code dump which would get down voted on any question.

But don't waste review queue time or moderator time on flags on these sorts of comments/answers.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .