assignment 2 solution from Richard Sayad