My code on cs194 of 2014 by Richard Eisenberg