Homework 2 for CS169