Adding Jitter to Overlapping Categorical Points
Meridian Insight plots customer satisfaction by store tier. A tier is a whole number, so every store in a tier lands on exactly the same across position and the dots stack into one narrow stripe with no readable shape. Each dot is therefore nudged sideways by a tiny random amount so the stripe spreads into something you can look at. The nudge changes where a dot is drawn and nothing else. Under the picture goes tier 1's headline figure.
Task: Print the average score across the stores in tier 1 only, ignoring every other tier. The nudged positions exist for drawing; the average must be taken from the tiers exactly as they arrived.
Input
The first line holds the seed for the random nudge. The second holds an integer n, the number of stores. Each of the next n lines holds two numbers separated by a single space: the tier, a whole number, then that store's score. At least one store is in tier 1.
Output
One line holding the average, printed as Python prints the number: an average of fifteen comes out as 15.0, not 15 and not 15.00.
Example:
Input:
1
4
1 10
1 20
2 30
2 40
Output:
15.0
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