my solutions to problem 4 & problem 5