Spotting Outliers on a Box Plot
Thornhill Labs pulls suspect readings out for a re-test. The box plot already marks them: anything past the end of a whisker is drawn as its own separate dot instead of being swept into the line. Behind those dots is a fence placed a box-and-a-half beyond each end of the box. The re-test paperwork needs the count of them.
Task: Print how many readings fall outside the fences. The box runs from the lower quarter mark to the upper quarter mark, using this lab's blunt rule: with the readings in order and positions numbered from 0, the lower mark is the reading at position n // 4 and the upper mark the reading at position 3 * n // 4, // discarding any remainder. Each fence sits one and a half box widths beyond its mark. A reading counts only when it is strictly outside a fence — one landing exactly on a fence is inside. Readings below the lower fence count just as readings above the upper one do.
Input
The first line holds an integer n, the number of readings. Each of the next n lines holds one reading, possibly with decimals, in no particular order. n is at least 1.
Output
One line holding a whole number: how many readings are flagged.
Example:
Input:
6
10
11
9
12
10
100
Output:
1
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