Solutions for p2 and p3

Got a sort of solution to p2 (there's some off by one error) and an
actual solution to p3.