completed problem 3

looked at SO similar solution to see how it was done.