solution part a for problem 2