A Donut Chart (Pie With a Hole)
Calder & Voss is styling a dashboard tile for a client. The circle has its middle cut out, leaving a ring — the client's designer prefers it because the hole gives somewhere to place a headline figure. Under the ring the review wants the weakest category called out as a percentage, since the thinnest band on a ring is the hardest of all to size by eye.
Task: Print the smallest category's share of the total, as a percentage. The total is every value in the list added together — do not assume the values already come to 100. If several categories are tied for smallest, they all share the same value, so the answer is the same whichever you take.
Input
The first line holds an integer n, the number of categories. Each of the next n lines holds a category name, one word with no spaces, then its value, separated by a single space. Values may have decimals. n is at least 1.
Output
One line with exactly 1 digit after the decimal point, given as a percentage rather than as a fraction. A tenth of the whole prints as 10.0.
Example:
Input:
3
A 60
B 30
C 10
Output:
10.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