Ad
  • Custom User Avatar

    This solution uses Ruby's combination method to generate all possible combinations of 2 elements from the input array. It then adds the sum of each combination to a hash, with the sum as the key and a value of true. If the sum is even, it will be added to the hash. Since a hash only allows unique keys, the size of the hash at the end will represent the number of distinct even sums.