My answer to CS101 problem set 3-7.