https://courses.grainger.illinois.edu/cs466/sp2020/assignments/PS2_sol.pdf