Code written for edx's 2013 CS50x Intro to CS course