P8: Updated answer and all solutions because problem statement changed, tweaked code.
P3, P15: Tweaked Haskell solution.
P2, P13, P22: Tweaked Mathematica solution.