solution to prog assignment 2