solved problem 31, using help from recursive algorithm defined elsewhere
solved problem 32, didn't use any references for this one