First pass at problem3 solution.