Understanding the IQR and Whiskers
Ironbark Manufacturing flags parts whose measurement sits far outside the normal run. The box chart already marks those as individual dots beyond its whiskers, using the standard rule, and the shift report needs the same count in text so it can be logged. The rule works from the quarter-points of the measurements: the value a quarter of the way up the sorted list, and the value three quarters of the way up.
Task: Print how many measurements are flagged.
Input
The first line holds one integer n, the number of measurements. Each of the next n lines holds one measurement, a number on its own. Measurements may be negative.
Output
One line holding a single whole number. Let Q1 be the lower quarter-point and Q3 the upper one, both taken by sliding evenly between the two neighbouring measurements when the quarter-point falls between them. A measurement is flagged when it is below Q1 - 1.5 * (Q3 - Q1) or above Q3 + 1.5 * (Q3 - Q1). Count both sides. Print 0 when nothing is flagged.
Example:
Input:
6
10
12
11
13
12
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