Finalize codes for problem1
Add solutions to ps2