implemented hw1 prob3