We have a tag and we've had it for a while now. Submissions are scored based on the time complexity of the algorithm. This means that the actual implementation has no effect on the score whatsoever (except if, say, actual runtime is used as a tiebreaker).

In particular, we had a challenge this week which explicitly asked for an algorithm, not necessarily with code.

It got such an answer (currently only visible to high-rep users), which promptly received a comment

This is not an answer. You have to post the actual code.

It was subsequently deleted by a mod.

For one thing I don't think it's fair to delete an answer to a question that explicitly doesn't require code. If we don't want to allow that, the question is at fault, not the answer.

But more importantly, do we really require code for such challenges? If so that should be made clear in the tag wiki, and the questions should ask for an example implementation.

  • 3
    \$\begingroup\$ For those who don't like to click, the offending part is "The objective is to give an algorithm (or some code) that given five tables of the form above, minimizes the total cost to complete all the tasks while making sure all the tasks are completed by their deadlines. If this isn't possible we just report that it can't be done." \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 12:42
  • 1
    \$\begingroup\$ Note that the answer was not flagged. It was simply voted to be deleted, which normally needs 3 delete votes and generally garner enough time for the user to respond back. Moreover, other users have the right to think and choose whether the question needs deletion or not. Unluckily, a mod came by and deleted it all by himself. (Which also meant that the answer cannot be voted for undeletion by normal users) \$\endgroup\$
    – Optimizer
    Commented Jan 21, 2015 at 13:37
  • \$\begingroup\$ Martin, as I've mentioned in my answer, the title question is a lot broader than the one mentioned in your text. Compression and Komologorov complexity questions can sometimes be appropriate for non-code answers, as well as fastest-algorithm. The mismatch means there's a risk of debating two quite different subjects here. You may want to edit your question accordingly. \$\endgroup\$ Commented Jan 24, 2015 at 12:38
  • \$\begingroup\$ @steveverrill Okay, I'll think about rewording it. My real question is the one in the title - it's definitely an important fundamental policy, we need to sort out. Fastest-algorithm was simply the most obvious tag where this applies. I don't think in kolmogorov complexity challenges you'd actually describe an algorithm. I'm with you on data compression challenges though, like the chess compression challenge. \$\endgroup\$ Commented Jan 24, 2015 at 16:46
  • \$\begingroup\$ So should the answer be undeleted? \$\endgroup\$
    Commented Jun 1, 2018 at 13:31

4 Answers 4


We should allow algorithm-only answers.

We currently accept code that is impossible to verify. Furthermore, we rarely actually run the code to verify anyways. Hence, the fact that it is impossible to test should be taken into consideration by the OP, but it should not prevent the OP from asking his question.

Furthermore, algorithm design definitely falls under Programming challenges. Designing an algorithm is one of the steps to programming. If I were to post a question that already has a predefined algorithm, and asks you to convert the algorithm into code (think code-golf), we wouldn't remove the question. Why shouldn't we allow people to simply post answers that only perform the Problem statement to algorithm step?

  • \$\begingroup\$ To me, the difference between a question asking for the final step and a question asking for an earlier step is that the final step can be tested. I'm already wary of answers that cannot be verified. \$\endgroup\$ Commented Jan 21, 2015 at 14:33
  • \$\begingroup\$ @trichoplax Being wary is certainly important for answers that can't be verified, but that doesn't mean we should remove them. \$\endgroup\$ Commented Jan 21, 2015 at 14:39
  • 2
    \$\begingroup\$ @trichoplax I personally think that a clear and unambiguous description in plain English is necessary for verification in any case. There is a limit to what you can learn from just running code. \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 14:46
  • 6
    \$\begingroup\$ @Lembik +1 What's worse than an answer with no code? An answer with only code. The description is just as important (or more, depending) to me when voting. \$\endgroup\$
    – Geobits
    Commented Jan 21, 2015 at 14:47
  • \$\begingroup\$ @Lembik I definitely agree that code on its own makes a poor answer. Explanation of the code and the process that led to it is a vital part of a good answer. \$\endgroup\$ Commented Jan 21, 2015 at 15:01

The question should specify whether code is required.

Where code is required, fastest-code is the best tag to use. If the search space is too large for this, we have the fastest-algorithm tag. It's up to the OP to decide which is appropriate in each case, with feedback from the community via comments.

An important caveat: All relevant parameters need to be considered in the big O (and frequently they aren't. In this case the OP seems correct in specifying both m and n should be considered (many OP's don't.) But as one comment points out, there is no need for the OP to consider d.

We have already discussed the issue of deletion in the following posts and the general consensus seemed to be that answers that missed the mark should be downvoted but not deleted.

What should count as "not an answer" here? and Should answers that break the rules be deleted?

Also discussed elsewhere, is what the OP's responsibilities are about verifying the answer before awarding the green checkmark. If the algorithm is unclear, the OP can always ask the answerer to clarify before awarding!

Finally, it's worth noting that while the text of this meta post considers fastest-code tag, there can also be non-code answers on compression and komolgorov complexity tagged questions, and these may need a different consideration, but this is not reflected in the current title of this question.

For example the following question has 23 upvotes, and very few answers contain any code. Any answer which contributes something should not be deleted.

Smallest chess board compression

  • \$\begingroup\$ Is the link to "Generate all 4-perfect numbers" in the wrong place? \$\endgroup\$ Commented Jan 25, 2015 at 17:42
  • \$\begingroup\$ PS Bob Dalgleish was wrong about d being irrelevant. \$\endgroup\$ Commented Jan 25, 2015 at 17:43
  • \$\begingroup\$ @PeterTaylor I've removed the link to my answer to "generate all 4-perfect numbers" because I've now added code to it (I wasn't sure I was going to, because it meant learning a new language.) However it should be noted that it was getting upvotes faster than the other two answers even when it was just a (very bulky) table of prime factorizations, because people could see the potential. The other answers contain code but are just general purpose number compression, taking no advantage of the specific problem. \$\endgroup\$ Commented Jan 25, 2015 at 18:50
  • \$\begingroup\$ As you say d is in fact relevant I've re-read the question and I think you're right. I misinterpredted the meaning of d the fist time I read it \$\endgroup\$ Commented Jan 25, 2015 at 18:59

Yes, all answers should contain code.

  • Without working code, there is no way to test the answer to verify that it works, to determine its score, etc.

  • If we allow algorithm-describing answers, then we'd also have to allow, say, answers that describe how you would write the code (without actually writing it), answers that claim they will work in a certain unreleased version of a language, etc., and we'd have no argument against those either. Essentially, it's a slippery slope.

  • Here's an analogy: We currently don't allow "theoretical" programming languages, i.e., languages for which there is no available working interpreter. It's the same problem: There's no way to actually test the algorithm.

  • This is called Programming Puzzles and Code Golf, not Algorithm Puzzles and Complexity Golf. There are only a few answers that lack code, most of which contain either images (Piet et. al.), improperly formatted code, or external links. A precedent for this has already been set.

  • 1
    \$\begingroup\$ +100 for "This is called Programming Puzzles and Code Golf, not Algorithm Puzzles and Complexity Golf" \$\endgroup\$
    – Optimizer
    Commented Jan 21, 2015 at 13:31
  • 4
    \$\begingroup\$ I really don't mind going with this decision, but I think all the points in this answer are pretty weak. 1. Code is no proof for correctness either. In that regard, I'd prefer an algorithm-only answer with a rigorous proof over an answer with code that happens to work for the test cases. 2. I don't know how you'd "describe how you would write the code". If a question asks for code, there has to be code that is executable. If the question asks for an algorithm, then I don't see what's wrong with answering with one. Algorithms themselves are not executable, so I don't get the comparison. [cont.] \$\endgroup\$ Commented Jan 21, 2015 at 13:37
  • 3
    \$\begingroup\$ 3. Again, I don't think it's a valid analogy. You are talking about challenges that require code. Those should obviously be given in a language where that code is executable. An algorithm is language-agnostic so the language it's presented in is irrelevant as long as it's unambiguous. 4. Just because we don't have many answers without code so far is no argument for disallowing them. We didn't have cops and robbers until a few months ago, and that's cool, too. Also, I think designing algorithms is part of programming. \$\endgroup\$ Commented Jan 21, 2015 at 13:39
  • 5
    \$\begingroup\$ What I'm saying is, if we don't want purely algorithmic challenges, I'm cool with that, but I don't think any of these arguments and analogies against such challenges is really cutting it. \$\endgroup\$ Commented Jan 21, 2015 at 13:41
  • 1
    \$\begingroup\$ Your SEDE query doesn't work so well. It simply looks for any code block, not actual code. Not that there's really a much better way to find them, but it misses great answers that have code-formatted blocks (like this one) with no actual code. \$\endgroup\$
    – Geobits
    Commented Jan 21, 2015 at 14:19
  • 6
    \$\begingroup\$ Geez, do all of you really want the fastest-algorithm tag declared off-topic? That's what this answer is basically arguing for, especially "This is called Programming Puzzles and Code Golf, not Algorithm Puzzles and Complexity Golf." \$\endgroup\$
    – xnor
    Commented Jan 22, 2015 at 5:21

No not all answers need to contain fully working code

  • Even with working code you can't necessarily check that an answer is correct. It might just work on a few cases. So it's not true that having code solves the problem of checking correctness.
  • We currently allow answers which would need to be included in a larger piece of code to be runnable. We don't require that all code is a complete piece of software that can just be cut and paste and compiled. So it's not true that pseudo code would be the only non-runnable thing we allow.
  • Pseudo code can be easier to verify for a non-specialist than an answer in code, especially if the code is in some minority language.
  • Currently when someone submits an answer in a minority language (APL for example) I rely entirely on their explanation in plain English to check if it is correct or not. The code adds little to this in practice.
  • I don't think we should get hung up on names (stackoverflow allows questions that don't relate to overflowing stacks). Some people regard algorithms as a constituent part of programming in any case.
  • Pseudo code allows much more sophisticated answers to be expressed succinctly. For example "Step 3. Insert x into a balanced binary search tree T" would involve a lot of code in most languages which might obscure the answer.

My view is that most questions should require code and that questions that don't should require clear and unambiguous pseudo code at least to accompany any plain English explanation.

  • \$\begingroup\$ I agree with a lot of your points, but I think setting a precedent of allowing questions that do not require code will cause more problems than is worthwhile. So -1 \$\endgroup\$ Commented Jan 21, 2015 at 14:18
  • 1
    \$\begingroup\$ @trichoplax it has been pointed out to me that there are already examples that people were happy with. For instance, codegolf.stackexchange.com/q/19397/14215 \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 14:19
  • 1
    \$\begingroup\$ I also don't run the code from most of the answers I read, but it's still there for someone to test, so problems that aren't obvious to most of us can still be pointed out by someone familiar with the language/prepared to run it. \$\endgroup\$ Commented Jan 21, 2015 at 14:19
  • \$\begingroup\$ @trichoplax Right but with clear unambiguous pseudo code you are more likely to be able to see if it is correct. You won't have to rely on the one expert. My point is not that this should be common, but merely that it should be allowed sometimes. \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 14:20
  • 1
    \$\begingroup\$ I only get one vote - others may disagree. So I recommend you edit all the relevant example questions into your answer. \$\endgroup\$ Commented Jan 21, 2015 at 14:20
  • \$\begingroup\$ The chess compression example is an interesting one in that the score is the compressed size rather than the code size. I'm in favour of the scoring method, but I'd still prefer it to include the code: Winner being shortest compressed size of those answers with working code. \$\endgroup\$ Commented Jan 21, 2015 at 14:28
  • \$\begingroup\$ @trichoplax Would you require that all answers have complete and fully working code that can just be copied and pasted and run? This would exclude a huge number of existing answers if so. See codegolf.stackexchange.com/questions/7189/… for example. \$\endgroup\$
    – user9206
    Commented Jan 21, 2015 at 14:29
  • \$\begingroup\$ I know you've already seen this, but for anyone else reading these comments, that separate discussion is located here: Program, Function or Snippet? \$\endgroup\$ Commented Jan 21, 2015 at 15:06

You must log in to answer this question.

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