1
\$\begingroup\$

Say Round to nicer numbers where it's possible to always output n'=m. I submitted a Javascript solution that does this.

I can require input be f(x,n,[m]) and then it's modifiable, but this doesn't apply for languages like C.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ I don't really know what this is even asking. The linked answer doesn't seem to do what the comments suggest, it doesn't even output by modifying any of the inputs, all it does is return a number \$\endgroup\$
    – Jo King Mod
    Commented Jan 10, 2023 at 10:37
  • \$\begingroup\$ Ah wait, is this asking whether you can "output" by leaving a variable alone if that output would be the always the same as the input value of that variable? \$\endgroup\$
    – Jo King Mod
    Commented Jan 10, 2023 at 10:40
  • \$\begingroup\$ @JoKing Modified tio \$\endgroup\$
    – l4m2
    Commented Jan 10, 2023 at 10:41
  • 1
    \$\begingroup\$ Yes, asking whether you can "output" by leaving a variable alone if that output would be the always the same as the input value of that variable \$\endgroup\$
    – l4m2
    Commented Jan 10, 2023 at 10:42

1 Answer 1

1
\$\begingroup\$

This should be considered as "output by modifying an input parameter"

I consider this somewhat borderline, but ended up slightly on the side of allowing it.

The challenge you linked requires "output x and n" (approximately). The answer you proposed "outputs x as the return value of the function, outputs n as the value remaining in m after the function runs". This is an entirely normal and permitted way to output. The internal facts of your program not actually modifying m are irrelevant to whether the answer is valid. I think the internal facts of your language not even allowing you to modify m are also irrelevant; as long as the user treats m as an output parameter (i.e. not changing its value somewhere else in the middle of running the function) then the answer successfully ensures that m contains the correct value after running.

\$\endgroup\$
1
  • \$\begingroup\$ Then consider case where one output is one input, and you don't need the input to do something else(cat without special IO requirement, happen sometime), can you claim a file read from and written into? Is it allowed to claim output to a.txt by calling foo < a.txt? \$\endgroup\$
    – l4m2
    Commented Jan 11, 2023 at 19:21

You must log in to answer this question.

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