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

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.

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

0 comment threads

19 answers

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.

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Technically, command line arguments go to stdin in most languages, don't they (2 comments)
+11
−0

Functions may take input via arguments and output via return value

Functions may also use STDIN/STDOUT as they wish.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Clarification needed (1 comment)
+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Restriction (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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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).

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

I'm not sure this needs to be said; it's a pretty obvious rule, but it might be good to have it writt... (2 comments)
+6
−0

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

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+5
−0

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

Similar to the exit code submission.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

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

History
Why does this post require moderator attention?
You might want to add some details to your flag.

2 comment threads

Same discussion in another Meta post (1 comment)
Clarification (2 comments)
+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Disagree (2 comments)
+5
−1

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

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Too vague (3 comments)
+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−1

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

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

2 comment threads

Non-observable behaviour (7 comments)
Non-trivial change (3 comments)

Sign up to answer this question »