Problem #31 and #36 Solution