Changed problem 31's solution to a more functional style. It's slower, though, and I think that's because I'm creating lots of arrays via map.