Assignment 5 solution