Counting Missing Sensor Readings
Northgate Water keeps a level sensor in the river at Milburn Weir. It is supposed to report once an hour, but when the radio link drops the logger writes the word nan into the slot instead of a level. nan is short for Not a Number, and it is the standard marker for a reading that never arrived — it is not a zero and not a low level. Before the duty engineer trusts a day's summary she wants to know how much of the day is actually missing.
Task: Print how many readings are missing.
Input
The first line holds an integer n, the count of slots in the log. Each of the next n lines holds either a level written as a number, or the exact text nan for a slot where no reading arrived.
Output
One line holding a single integer: how many of the n slots are missing. Print 0 if none are.
Example:
Input:
4
10
nan
20
nan
Output:
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