Finished and polished problem 2 of HW02.