Solution to sum_of_min_and_max()