LearnPy Hub
← NumPy problems
Hard

Histogram Counts

Read numbers and a number of bins k. Use np.histogram(a, bins=k) to split the range from the smallest to the largest value into k equal bins. Print each bin as [lo, hi) count with lo and hi to 2 decimals (the last bin includes its right edge, so write it as [lo, hi]), then the index of the fullest bin (first if tied).

Input

Numbers, then k.

Output

k + 1 lines.

Sample 1

Input
1 2 2 3 3 3 4 4 5
4
Output
[1.00, 2.00) 1
[2.00, 3.00) 2
[3.00, 4.00) 3
[4.00, 5.00] 3
2

Sample 2

Input
10 20
2
Output
[10.00, 15.00) 1
[15.00, 20.00] 1
0
solution.py
Output appears here
Histogram Counts · Python practice problem · LearnPy Hub