32
4
Consider a stream/file with one integer per line. For example:
123
5
99
Your code should output the sum of these numbers, that is 227
.
The input format is strictly one integer per line. You cannot, for example, assume the input is on one line as an array of integers.
You can take input either from STDIN, in form of a filename, or a file with a name of your choice; you can choose which one. No other ways of getting input are allowed.
The input will contain at least one integer. You can assume all integers are non-negative and that their total sum is less than 232
.
2Is there a trailing newline? Is that newline optional? – Please stop being evil – 2017-03-24T06:50:06.897
9
Hi! I downvoted this challenge because it goes against our community standards for acceptable input/output formats by having a restrictive input format.
– AdmBorkBork – 2017-03-24T15:34:22.4501@AdmBorkBork and I discussed this at length in the chat room. We have agreed to disagree :) – None – 2017-03-24T17:09:28.227
22
As the author of the things-to-avoid of cumbersome I/O and arbitrarily overriding defaults, I want to defend this challenge on those grounds. Here, the processing input is the meat of the challenge, not extra work that distracts from the main challenge. It's not "add numbers" with weird I/O requirements, it's "do this I/O" with adding as a step. Overruling the standard I/O is necessary for answers not to shortcut across the main task.
– xnor – 2017-03-24T18:58:12.487@ais523 Ahem.
– Dennis – 2017-03-25T11:39:29.313@Dennis: OK, I didn't think of that. Still fairly ridiculous that you have to go to those lengths, though. – None – 2017-03-25T17:09:02.347
2Why can't function input be used? – CalculatorFeline – 2017-04-09T21:02:07.807