Solution for the final homework problem