The ASCII Histogram
Selby Council times how long residents wait on hold before someone answers, and the service report shows the shape of those waits rather than a single average. It uses five fixed bands, each twenty seconds wide, covering the first hundred seconds. A band nobody landed in is still part of the shape, so the report always prints all five rows.
Task: Print how many waits fall into each of the five bands.
Input
The first line holds one integer n, how many waits follow. Each of the next n lines holds one wait as a whole number of seconds from 0 to 99. Waits arrive in no particular order and several may land in the same band.
Output
Exactly five lines, lowest band first. Each line reads lo-hi: count — the band's first second, a hyphen, the band's last second, a colon, one space, then how many waits landed in it. The five bands are 0-19, 20-39, 40-59, 60-79 and 80-99. A band with nothing in it prints a count of 0.
Example:
Input:
6
5
25
45
65
85
90
Output:
0-19: 1
20-39: 1
40-59: 1
60-79: 1
80-99: 2
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