0
\$\begingroup\$

Should questions (code-golf) include an algorithm used to find the answer in its description? I feel like that whole point of code-golf is to come up with your own algorithm of solving a problem, something shorter-to-write than others, which is the hardest (and most fun part) IMO. If you are given the algorithm, isn't this just basically a translate-pseudocode-to-golfing-language contest?

Here are some examples of questions that do this:

I understand some kind of have to, or else it would be unclear what you were supposed to do. Examples of this:

(I am finding more examples - if you have any please share them)

\$\endgroup\$

2 Answers 2

4
\$\begingroup\$

The two questions you have there are based on a user-defined construction. There are many parameters that could have been arbitrarily chosen - taking the hexa-glyph example, this could be what edges combinations are valid, since this is difficult to infer by looking at the final output glyphs alone. These types of questions should definitely be explicit about what algorithm was used and what leeways are allowed, so that submissions can be checked against the spec.

Of course, that doesn't mean there isn't any creative freedom when golfing - just because an algorithm is given doesn't mean you can't find your own way to produce an equivalent result. A good example of this is Shotgun Numbers - a direct implementation of the algorithm described would be far too expensive to be useful in most languages. In this case, finding an alternative short algorithm consitutes most of the fun in the question. As a further example, you'll notice that Martin's solution deviates from the algorithm described in hexa-glyphs, not using the outer points for golfitude, so it's certainly not a "pseudocode-to-language" contest.

\$\endgroup\$
0
\$\begingroup\$

It should not be required, but for challenges dealing with sufficiently complicated and/or esoteric goals, an example algorithm to help solve the challenge is not a bad idea. I personally recommend including at least the name of an algorithm that can be used to solve the challenge if it's unlikely that many people are knowledgeable about the problem and/or the algorithm. For example, including information about a sorting algorithm in a sorting challenge would be superfluous, as sorting is one of the most elementary classes of problems in computer science (unless the specific challenge involved using a specific, esoteric sort). However, a challenge about simulating a quantum computer to factor an integer would definitely benefit from mentioning Shor's algorithm.

In other words, use your judgement. Do whatever you think would be the best for each of your challenges.

\$\endgroup\$

You must log in to answer this question.

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