Assignment 4 solution