hackerrank ruby hash each problem solution