I've been trying unsuccessfully to solve a problem I was asked during an interview, it was exactly like this:
Consider the following structure in Ruby:
['dog', 'donkey', 'cat', 'cow', 'horse']
How would you turn it into this one:
{ 'd' => ['dog', 'donkey'], 'c' => ['cat', 'cow'], 'h' => ['horse'] }
Being as idiomatic as possible ?
I have tried a lot of ways, and only have gotten close, and also have seen many similar problems around, but never a solution to this one in particular,
How would you guys do it? Can you help me solve it?
Best Regards,