Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Meta

Comments on Default Rules: Code Golf Answer Types

Parent

Default Rules: Code Golf Answer Types

+0
−0

When answering a code-golf challenge, what types of answer are acceptable by default? Can an answer be a complete program, a function, an anonymous function, a snippet of code?

Please add one type per answer. An answer can express that a particular type is acceptable, or that it is not acceptable. Since voting up and down on answers will indicate community consensus, edge cases for particular languages or unusual circumstances can be added as separate answers.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+0
−0

A snippet is not a valid answer

A code golf answer must in general be able to take input[1] and give output. A snippet of code that is not contained in a function or program cannot take input[2], instead requiring the input value to be inserted directly into the code. This is not an acceptable type of answer, with the exception of programming languages for which there is no other way to take input.

This reflects the insertion into the source code rule from Default Rules: Code Golf I/O.


  1. Some challenges require no input, such as some random output challenges or kolmogorov-complexity challenges. In such cases I would expect the "snippet" to work as a complete program, so these don't seem applicable here. ↩︎

  2. If a "snippet" takes input from STDIN, I would expect it to work as a complete program, so that doesn't seem applicable here. ↩︎

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Vague definition of "snippet" (1 comment)
Vague definition of "snippet"
trichoplax‭ wrote 3 months ago

This answer is the one I am least confident of. It isn't clear what counts as a "snippet" of code, making it difficult to know how to interpret this answer. I've added this answer as a starting point for discussion. Please mention any exceptions or edge cases.