http://www.cs.cornell.edu/Courses/cs280/2003fa/HW/280hw2s.pdf