solution of HW3 and 4