Guest User

Untitled

a guest
Dec 2nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Starting from an array of sub-arrays, each sub-array is a 2 elements key|value pair. Example
  2.  
  3. input = [[:A, 5], [:B, 2], [:A, 12], [:B, -2], [:C, 7]]
  4.  
  5. Convert this into a hash that has distinct keys from above, with values summed up, so the above would be:
  6.  
  7. output = {:C 7, :B 0, :A 17}
Add Comment
Please, Sign In to add comment