added a very imperativ solution for problem 2
using sum now
switched to sum (from reduce)