Add problem 2 solution with naive implementation