added solutions to p1 and p2, and code for p1 and p2