Haskell #5: Solution (brute-force)