Skip to main content
5 of 6
added 80 characters in body
syb0rg
  • 1.1k
  • 7
  • 23

Histogram generation

Write the shortest program that generates a histogram (a graphical representation of the distribution of data).

Rules:

  • Must generate a histogram based on the character length of the words (punctuation included) input into the program. (If a word is 4 letters long, the bar representing the number 4 increases by 1)
  • Must display bar labels that correlate with the character length the bars represent.

Examples:

$ ./histogram This is a hole in one!
1 |#
2 |##
3 |
4 |###

$./histogram Extensive word length should not be very problematic.
1 |
2 |#
3 |#
4 |##
5 |
6 |##
7 |
8 |
9 |#
10|
11|
12|#

./histogram Very long strings of words should be just as easy to generate a histogram just as short strings of words are easy to generate a histogram for.
1 |##
2 |#######
3 |#
4 |#######
5 |###
6 |#
7 |##
8 |##
9 |##
syb0rg
  • 1.1k
  • 7
  • 23