http://www.cs.berkeley.edu/~sinclair/cs170/sol1.pdf