Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- # coding: utf-8
- ret = Hash.new {|hash, k| hash[k] = 0 }
- DATA.each_line do |line|
- keys = line.split(':')
- val = keys.pop.to_i
- keys.each {|k| ret[k] += val }
- end
- ret.each {|k, v| puts "#{k}: #{v}" }
- __END__
- a:b:c:10
- a:e:20
- b:e:30
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement