https://courses.grainger.illinois.edu/cs522/sp2016/522HW2.pdf