### Communities

tag:snake search within a tag
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
created:<1w created < 1 week ago
post_type:xxxx type of post
Meta

# Default Rules: Code Golf I/O

+8
−0

What input/output methods do you think should be allowed/disallowed while code golfing on this site? What guidelines for input/output methods do you think should be in place?

One method per answer, please. Vote up/down according to if you believe the given method should be allowed.

Why does this post require moderator attention?
Why should this post be closed?

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+7
−0

## Functions may take multiple arguments with currying

For some languages like Haskell this is almost a necessity, as only one-argument functions exist and multi-argument functions are implemented with currying. (You might take a list or tuple of the values but this isn't the natural way to do multi-arg functions in Haskell.)

The same thing should be allowed for languages which do have proper multi-argument functions. In JavaScript, one might want to use f=a=>b=>... and call f(a)(b) instead of using f=(a,b)=>... and calling f(a, b).

Why does this post require moderator attention?

+11
−0

# Functions may take input via arguments and output via return value

Functions may also use STDIN/STDOUT as they wish.

Why does this post require moderator attention?

Clarification needed (1 comment)
+8
−0

# Functions may use arguments or lists of arguments interchangeably

For example, if a challenge requires defining f(x, y, z), f(a) is also acceptable where a[0] = x, a[1] = y, a[2] = z.

Why does this post require moderator attention?

+8
−0

# You may output delimiter-separated values instead of a list

For example, the output [1,2,3] could be represented as 1 2 3 or 1|2|3.

Why does this post require moderator attention?

Restriction (1 comment)
+7
−0

## Programs may take input from prompts from the GUI

For Mathematica, JS, Matlab, et. al. this is the closest thing they have to STDIN.

Why does this post require moderator attention?

+6
−0

## Regexes may output via the list of matched strings (capture group 0)

Why does this post require moderator attention?

+6
−0

## In languages without STDIN (eg ///) programs may input through insertion into the source code

Also applies to cellular automata, in which the most natural way of taking input is specifying some space for a user-created structure.

Why does this post require moderator attention?

+5
−0

## Turing machines supporting multiple halt states may output with the state they halt on

Similar to the exit code submission.

Why does this post require moderator attention?

Applying this to other languages (1 comment)
+5
−0

# You may modify the input in-place

If a function takes an input a, it is acceptable that a contains the intended output after executing instead of other forms of output. Note that this means a must be mutable to begin with and the function must actually mutate a.

Example

Why does this post require moderator attention?

Same discussion in another Meta post (1 comment)
+4
−0

## Numerical I/O may be given as a character code

Input 64 may be given as @ instead. This mostly exists for languages like Brainfuck that only take input through character codes.

Why does this post require moderator attention?

+7
−1

## Unless explicitly asking for exactly two values, you may use any truthy/falsey values in decision problems

For instance, considering the hypothetical challenge "Determine if a number is non-divisible by 3", n=>n%3 would be a valid solution, as it outputs a truthy (non-zero) value when it is non-divisible and a falsey (zero) value when it is.

Why does this post require moderator attention?

+7
−1

## Programs may output via exit code

Exit codes are to programs what return values are to functions, so it makes sense that exit codes would be allowed.

Why does this post require moderator attention?

+4
−0

## Command-line arguments may be used as input instead of stdin

Languages/systems that support reading input from command-line arguments may use those as input instead of reading from stdin.

Why does this post require moderator attention?

+5
−1

## Turing machines may use the contents of their tape pre-execution as their input

Why does this post require moderator attention?

+1
−0

## Image output may be a pixel shader

A pixel shader inputs x,y coordinates of a pixel and prints the color of a pixel (scalar for grayscale, tuple for full color, bool for binary...). Relevant for Shadertoy/GLSL answers and graphical output challenges.

Why does this post require moderator attention?

+2
−1

## Functions may return bools via the presence/absence of an error

Crashing to mean false and not crashing to return true. Another branch of the exit code answer.

Why does this post require moderator attention?

+2
−1

## Programs/functions may use the presence/absence of output as a bool

Why does this post require moderator attention?

+0
−0

## A program may use IOs for input and output.

A input can be read via IO, which can be a port with (multiple) IOs each IO reads a symbol (a bit or more when you have a ADC). Or it can come from frames, such as UART frames, I2C, SPI, Ethernet, .... (any bus you like).

And Output can be done the same but reversed.

Why does this post require moderator attention?

+0
−2

## A program may output a boolean value by using different amount of time or instructions till it returns.

If a program needs to determine a boolean value, it may return in less than N second (or instructions) when the value is false but take longer than N + ϵ second (or instructions) when the value is true or vice versa.

The difference (ϵ) has to be large enough to be detectable without much effort. I would suggest there is a factor of at least 16 between true and false (i.e. $ϵ > 15 \cdot N$) . A infinite ϵ should be allowed (if it doesn't return after N second, kill it and consider the result as true). The poster has to give an estimate of N.

Why does this post require moderator attention?