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

Under which condition is a function that takes arguments other than those specified by the challenge by itself a valid solution to a challenge?

+3
−1

On my challenge Looping Counter there are several entries like this which contains a function which needs to be called with the right parameters to give the correct output. In this particular case, you get the desired output if and only if the function is called as f(3,2); any other call gives a wrong result.

The linked TIO code contains that call, but only in the footer part that is not counted to the solution.

I consider that as invalid, as the code as is does not contain all the information needed to generate the intended output.

If it is to be considered a valid solution,the question is how much can we omit without making it an invalid solution. Because clearly we would not want the following “solution” to the task “output the first 100 decimals of pi”:

f(char*s){puts(s);}

called from non-counted code that passes a string containing the first 100 decimals to the function.

I think we need a general rule to decide if such a submission is valid or not. Note that there are several such solutions already to this challenge; I'd not be surprised if such solutions are sent to other challenges as well.

So my question is:

Under which condition is a function that takes arguments other than those specified by the challenge by itself a valid solution to a challenge?

My preferred solution would be that a function is a valid solution to a challenge if and only if it can be called with no more than the specified input of the task (which in this case would be, none at all). That is, in the answer linked above, the function as is does not solve the problem, but giving the arguments default values of 3 and 2 (so that it can be called as f() instead of f(3,2)) would make it a valid solution.

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

1 comment thread

Regarding the specific example (3 comments)

1 answer

+3
−1

What you said

a function is a valid solution to a challenge if and only if it can be called with no more than the specified input of the task

This sounds reasonable to me. If you want to make your function take in specific parameters, code in defaults, or write a program instead.

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

0 comment threads

Sign up to answer this question »