Spotting an Outlier With the IQR Rule
The support lead at Whetcode is tidying last week's ticket log before it feeds the monthly report. She is fairly sure one row is a typing mistake — somebody entered hours where the form wanted minutes — but she will not delete rows on a hunch, and she wants a check she can rerun every Monday without re-reading the data by eye.
The agreed check is the standard boxplot rule: a value is suspicious when it sits more than 1.5 interquartile ranges below the lower quartile or above the upper quartile. Quartiles are interpolated linearly between the two neighbouring sorted values — the default your numeric library uses — because on most weeks no observation lands exactly on a quartile. Some weeks the check finds nothing at all, and that is a perfectly good answer.
Task: Print a Python list of the flagged values, in the order they appear in the log.
Input
The first line holds one integer n, the number of tickets closed that week (at least 4). The second line holds the n resolution times in whole hours, separated by spaces, in the order the log records them.
Output
One line holding a Python list of the flagged times as whole numbers, printed exactly as Python prints a list — [100], or [] when nothing is flagged.
Example:
Input:
10
12 15 14 10 100 13 16 11 14 15
Output:
[100]
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