The Missing Readings
Back at Northwind Cold Storage, freezer probes sometimes fail to answer. When that happens the logger still writes a line, so the log keeps one line per hour, but the line holds the text NA instead of a temperature. The overnight report has to average the hours that were actually measured: a failed read is a hole in the data, not a reading of zero degrees.
Task: Print the mean of the readings that are not missing.
Input
The first line holds one integer n, how many log lines follow. Each of the next n lines holds either one reading as a plain number or the exact text NA, meaning that hour's read failed. Missing lines can appear anywhere in the log, including at the very end, and at least one line is a real reading.
Output
One line holding the mean of the real readings, with exactly two digits after the decimal point.
Example:
Input:
5
10
NA
20
NA
30
Output:
20.00
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