Simplified problem 50 using a summing-reducer