skeleton for problem 7
Initial [slow :(] solution to problem 7