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 I/O

Parent

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

Post
+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)
Non-observable behaviour
trichoplax‭ wrote 8 months ago

Generally I prefer a challenge to be specified in terms of its output, rather than its internal workings. So "the output must meet these criteria" rather than "you must use this algorithm". It is easy to verify that the output is correct, whereas it is difficult to prove that a particular algorithm is being used (code can be misleading even before it is golfed).

For the same reason, I am wary of allowing a non-halting program, as the quality of being non-halting is not in general measurable.

I don't feel so strongly that I would want to prevent a challenge author from allowing this in a specific challenge, but I feel uncomfortable with it being allowed by default.

Part of the appeal of code golf is that it is easy for anyone to verify that the code works correctly, and everyone can agree on the score. Introducing a time limit means that the code could be considered non-halting on one machine but not on another.

H_H‭ wrote 7 months ago

I agree.

Changed the suggestion and now use always a limited runtime which measurable.

trichoplax‭ wrote 7 months ago · edited 7 months ago

The time limit is a big part of my concern. Everyone can agree on how many bytes there are, but different computers will have different speeds and therefore different outputs if based on run duration.

H_H‭ wrote 7 months ago · edited 7 months ago

The point is that there is large factor between both, so it easy to test, even on different computers. Automatically: Run it once where you know the the runtime will be fast, measure it, multiply it by 4. Use this time as a limit, if it stops before you know it had a fast runtime if not, it had a long one. For a human it is easy to tell the difference, so manual testing shouldn't be a problem.

It would allow some solutions where in one case the program ends in a few ms and in the other it runs infinitely long. This can make code smaller and is very easy to test.

trichoplax‭ wrote 7 months ago

It's tempting to think that multiplying by 4 would always be enough, but in general the duration on one computer will not scale linearly to the duration on another computer. For different code the scaling factor will be different (even for different solutions to the same challenge).

I agree it could work well for some solutions to some challenges. For this reason I'd like to see it permitted but only if specified by the challenge author. I wouldn't want this to be a default as it puts a burden on challenge authors who haven't chosen it.

H_H‭ wrote 7 months ago

Is there a requirement that the author can test it? Many solution are platform specific and i don't think most authors have all the platforms, interpreters and compilers a solution can use.

trichoplax‭ wrote 7 months ago

That's a good point. Currently the only restriction I can find is against non-free languages, and that only applies to one challenge type (so not to code golf):

This doesn't change my opinion (I would still prefer output by run duration / non-halting to not be a default) but it does weaken my argument.