Print the length of words as input as a histogram with horizontal bars Input

A list of words separated by any number of spaces.

Output

A horizontal ASCII art histogram, where the n-th line is composed by as many asterisks (*) as the n-th word is long.

Example usage

The &gt; signals user input, you should not input it when testing the program.

&gt; This is an example histogram of word length
****
**
**
*******
*********
**
****
******




&gt; a aa aaa aaaa aaaaa
*
**
***
****
*****




&gt; double space  example
******
*****
*******


The code

puts gets.chomp.split.map{|word| '*' * word.length}.join("\n")
Looks good. There's really not a lot to review. About the only thing I can think of is that I'd like a little breathing space in the block, i.e.

{ |word| "*" * word.length }


But that's about it :)

Of course, there are also other ways to go about this, for instance:

puts gets.chomp.gsub(/\S/, "*").gsub(/\s+/, "\n")


Not that that's necessarily any better.