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 Under which condition is a function that takes arguments other than those specified by the challenge by itself a valid solution to a challenge?

Post

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 attention from curators or moderators?
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)
Regarding the specific example
Lundin‭ wrote over 2 years ago

The challenge explicitly said to produce an infinite loop. Any answer implementing a size parameter is therefore not following the requirement, for that reason alone. I remember misunderstanding it at first and making a solution based on a finite counter based on user input. Perhaps it should have been tagged as "kolmogorov-complexity"?

celtschk‭ wrote over 2 years ago

Does kolmogorov-complexity apply to infinite loop output?

Anyway, this question, while referring that specific challenge, is more general: The same would apply e.g. to a challenge where you are asked to calculate something based on a single input variable, and the solution takes a second argument without default value to which it needs to be passed a specific value in order for the function to solve that. As a simple (silly) example, say the task is "add 1 to a given number" and the solution is f(a,b): return a+b, which the testing code calling it like f(number, 1)

celtschk‭ wrote over 2 years ago

I've now added a separate question about whether the tag would be appropriate.