Modeled Problem 5 on the haskell solution. It's speed is less than a millisecond instead of 4 seconds.