P1, P6, P9, P14, P15, P16, P19, P20, P26, P39: Tweaked Haskell solution, added comments.