Refactored problems 31, 32, 34 & 35