All problems

Choosing an Explicit Bin Count

easyPythonSeabornbins

Calder Health's chart tool lets an author say how many buckets to cut the readings into rather than how wide each should be. The tool works the width out by spreading the span of the readings evenly across that many buckets. Authors keep choosing bucket counts that produce absurd widths, so the width is printed for review before the chart is accepted.

Task: Print the width each bucket would have.

Input

The first line holds one integer n, the number of readings. Each of the next n lines holds one reading, a number on its own. One final line, after all the readings, holds an integer: how many buckets are wanted.

Output

One line with exactly two decimal places: the span from the smallest reading to the largest, shared evenly between the requested number of buckets. The span starts at the smallest reading, not at zero.

Example:

Input:
4
0
10
20
30
3

Output:
10.00

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…