P10: Simplified Java solution.
P11: Added Haskell solution.