First pass at solution to AST610 HW2 problem 4