10
\$\begingroup\$

A number of questions get posted here by people trying to solve problems from sites like interviewstreet.com. The site is intended to test programmer ability. Can you figure out the efficient algorithm?

What tends to happen is somebody writes the brute force implementation and then posts it here for a code review because it doesn't run fast enough for the online judge. At that point, somebody points out what the better algorithm would be.

The concern is that asking for help on something like this defeats the purpose of the site. So how do we want to handle them here?

Options:

  1. Do nothing
  2. Require such questions to be tagged with a special tag, and only give hints about the correct solution
  3. Close such questions on sight.
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Firstly, these questions don't really get the same kind of feedback as the other questions.

Most questions on this site get feedback on style. Ways are suggested to make code more readable, follow conventions, etc. People asking these questions neither want nor need advice on improving their style. Style simply doesn't matter for these kind of questions. As a result, a large portion of what would normally be good input on code doesn't apply.

Most of the performance improvements suggested on this site fall into the category of avoiding stupid things. This is not universally true, some of the answers do delve away into coming up better algorithms. But in doing so, they really aren't reviewing code anymore. If your developing better algorithms you aren't really doing a code review anymore. Its not necessarily wrong to provide a better algorithm, but its a very different focus from the other questions.

Secondly, the code in these questions seems superfluous. They are all just an implementation of the brute force solution to the problem. The correct answer to these questions doesn't involve the code at all. Rather, the correct answer points out where they need to look for a better approach. These questions then aren't really about the code, and this site is about the code.

Thirdly, the asker isn't required to show effort. It looks like they've made effort because they've produced a naive solution. But in the case of contest solutions, the naive effort doesn't count for anything. What we should be asking is whether the asker has made any attempts to come up with a better algorithm.

In summary: these questions require noticeably different answers then other code review questions. They aren't really about the code. They don't show effort on the part of the asker. In my judgment, these questions ought to marked off-topic and closed on this site.

\$\endgroup\$
7
  • \$\begingroup\$ I'm reading it again and again, and it seems true for every trivial question, not just the specific category. So, again, I don't think there's any need for any special treatment. If a question shows the characteristics you describe, there are other safeguards in place (I hope)... \$\endgroup\$
    – yannis
    Jan 21, 2012 at 14:30
  • \$\begingroup\$ @YannisRizos, but it seems to me that these contest-questions don't get treated like trivial questions. Other questions like this would get closed, but the contest questions remain open. \$\endgroup\$ Jan 22, 2012 at 14:20
  • \$\begingroup\$ Hmmm... Can you post some examples? \$\endgroup\$
    – yannis
    Jan 22, 2012 at 14:36
  • \$\begingroup\$ @YannisRizos, codereview.stackexchange.com/questions/6757/… for one. \$\endgroup\$ Jan 22, 2012 at 20:01
  • \$\begingroup\$ Counter examples: codereview.stackexchange.com/questions/7521/… & codereview.stackexchange.com/questions/4347/… :) I don't see anything wrong with the answers on those... \$\endgroup\$
    – yannis
    Jan 22, 2012 at 20:26
  • \$\begingroup\$ @YannisRizos, those answers were fine. Its just that those answers weren't really what the OP came here looking for. \$\endgroup\$ Jan 27, 2012 at 0:25
  • 1
    \$\begingroup\$ There is now a time-limit-exceeded tag for these kinds of questions, which you may choose to ignore. \$\endgroup\$ Aug 31, 2014 at 16:34

You must log in to answer this question.

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