CS 221: Completed problem 1