Post History
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], ...
Answer
#2: Post edited
- ## 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, 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](https://codegolf.codidact.com/posts/282784/282794#answer-282794).
[^1]:Some challenges require no input, such as some [random](https://codegolf.codidact.com/categories/49/tags/5333) output challenges or [kolmogorov-complexity](https://codegolf.codidact.com/categories/49/tags/4275) challenges. In such cases I would expect the "snippet" to work as a complete program, so these don't seem applicable here.
- ## 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](https://codegolf.codidact.com/posts/282784/282794#answer-282794).
- [^1]: Some challenges require no input, such as some [random](https://codegolf.codidact.com/categories/49/tags/5333) output challenges or [kolmogorov-complexity](https://codegolf.codidact.com/categories/49/tags/4275) 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.
#1: Initial revision
## 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, 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](https://codegolf.codidact.com/posts/282784/282794#answer-282794). [^1]:Some challenges require no input, such as some [random](https://codegolf.codidact.com/categories/49/tags/5333) output challenges or [kolmogorov-complexity](https://codegolf.codidact.com/categories/49/tags/4275) challenges. In such cases I would expect the "snippet" to work as a complete program, so these don't seem applicable here.