Beginner Haskell solution to Problem 1