Solve problem 31
Small tweaks to solution for problem 21
Solve problem 32