The Corrupted Column
Oakmere Retail imports a daily takings column from tills that occasionally write junk into it — a till losing power mid-write leaves a fragment behind, and one older model writes ?? whenever its display fails. The accounts run has to total everything it can read and, just as importantly, say how many lines it could not, because a total that quietly skipped a third of the tills is more dangerous than no total at all.
Task: Print the total of the readable values and how many values could not be read.
Input
The first line holds one integer n, how many values follow. Each of the next n lines holds one value: either a number, which may carry a decimal point, or arbitrary text that is not a number at all.
Output
Two lines, the total first. The first reads sum, one space, then the total of the readable values with exactly one digit after the decimal point. The second reads corrupted, one space, then how many values could not be read. Both labels are lowercase.
Example:
Input:
5
10
oops
20.5
??
30
Output:
sum 60.5
corrupted 2
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in