0
\$\begingroup\$

This issue has come up after receiving an answer to one of my questions. For the sake of clarity, I asked programs to take in two pieces of input. This answerer found it easier to read the two inputs in as one string and to not put a separator between them (since been changed). 1) Is it reasonable for me to enforce the requirement for two inputs. 2) What does it mean to have multiple inputs when they are coming from STDIN? Do they need to be separated by new lines? Some separator? 3) Finally, is it within the answerer's rights to read multiple inputs into one variable, as such combining multiple inputs into one, or should we require the answerer to read each input into a separate variable?

It's very easy to enforce multiple inputs in the context of functions or program arguments, but with STDIN it's less clear.

Update:

In light of the knowledge that it is acceptable to read multiple inputs for functions as a single array parameter, rather than multiple parameters, I now see that as equivalent to reading in delimiter-separated input from STDIN. However, I think a delimiter should be required.

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

In general, input should be allowed to be taken in whatever form is most convenient for the language/submission.

To address your specific concerns:

  1. Rather than enforcing reading separate inputs, you could enforce the use of a delimiter in the input. Often challenges will say that input will be given with a delimiter of the answerer's choice.

  2. By default, when multiple inputs are coming from STDIN, they can be delimited by spaces, newlines, commas, etc.—whatever is most convenient for each answer. Occasionally challenges enforce the use of a specific delimiter.

  3. Not all languages even have a concept of variables. Input should be able to be read however is most convenient for the answerer.

You also said:

It's very easy to enforce multiple inputs in the context of functions or program arguments, but with STDIN it's less clear.

By default, multiple inputs don't have to be separate function arguments; the function can take a single array argument, a delimited string argument, or (as I seem to keep saying) whatever is most convenient for the answerer.

I would recommend that as the challenge maker you should focus on an interesting task rather than on I/O technicalities, as we have a set of defaults that make things unambiguous and allow languages to play to their individual strengths. You're free to make any requirements you want, but often very strict I/O requirements will not be well received by the community.

\$\endgroup\$
3
  • \$\begingroup\$ So would you say having no delimeter is fair? \$\endgroup\$
    – geokavel
    Dec 20, 2015 at 4:40
  • 1
    \$\begingroup\$ @geokavel That's an odd case but personally I think it's fine. \$\endgroup\$
    – Alex A.
    Dec 20, 2015 at 4:54
  • \$\begingroup\$ @geokavel I mean odd as in I don't think it's very often that not using a delimiter will be more convenient than using one. \$\endgroup\$
    – Alex A.
    Dec 20, 2015 at 5:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .