saw something similar somewhere as a test for job seekers
so don't know if someone will help you as it's not so hard to solve
tom
saw something similar somewhere as a test for job seekers
so don't know if someone will help you as it's not so hard to solve
tom
Michael Pavling, thanks for reply.
Okay, i agree that is a array of hash : list.class => Array end list.last.class => Hash. But your solution only removes duplication and the sum of :val ?
Tom Meinlschmid, thanks for reply.
Not a test for job seekers
Solution:
list.inject(Hash.new(0)) { |hash, el| hash[el[:cod]] += el[:val] ; hash }
Michael Pavling, thanks for reply.
Okay, i agree that is a array of hash : list.class => Array end list.last.class => Hash. But your solution only removes duplication and the sum of :val ?
I think you need to make it more clear what you are trying to achieve. The sentence " But your solution only removes duplication and the sum of :val?" does not make sense.
Colin
Iām sorry if it made no sense to my sentence. The next will be clearer.