fork download
  1. def vowelhistagram(string)
  2. string.each_char.with_object(Hash.new(0)) {
  3. |obj, hsh| obj =~ /[aeiouAEIOU]/ ? hsh[obj] += 1 : nil
  4. }
  5. end
  6.  
  7. print vowelhistagram("Alright well lets see if this works")
Success #stdin #stdout 0.05s 9600KB
stdin
Standard input is empty
stdout
{"A"=>1, "i"=>3, "e"=>4, "o"=>1}