https://www.edx.org/courses/MITx/6.00x/2013_Spring/courseware/Week_6/Problem_Set_6/