···77```haskell
88import Data.List.Split (splitOn)
991010-parse :: String -> [[Integer]]
1010+type Point = [Integer]
1111+1212+parse :: String -> [Point]
1113parse = map (map read . splitOn ",") . lines
1214```
1315···1820This part requires us to simply find a rectangle with the largest area among the points given to us, so first write a method to compute areas given a point. Remember that our representation of a point is `[x, y]`:
19212022```haskell
2121-area :: [Integer] -> [Integer] -> Integer
2323+area :: Point -> Point -> Integer
2224area [x, y] [x', y'] =
2325 (1 + abs (x - x')) * (1 + abs (y - y'))
2426```
···2628Thus, the solution to the first part is given by the following list comprehension:
27292830```haskell
2929-p1 :: [[Integer]] -> Integer
3131+p1 :: [Point] -> Integer
3032p1 poly = maximum [area p p' | p <- poly, p' <- poly]
3133```
3234···3739Luckily, the intersections are quite easily calculated, since all lines of the polygon are oriented along the axes, and so are the lines forming the rectangle. If a line of the polygon falls to the left of the leftmost line of the rectangle, or to the right of the rightmost line, or above the topmost line, or below the bottommost line, then the line does not intersect the rectangle:
38403941```haskell
4040-intersects :: [Integer] -> [Integer] -> [[Integer]] -> Bool
4242+intersects :: Point -> Point -> [Point] -> Bool
4143intersects [x, y] [x', y'] = not . all away . pairs
4244 where
4345 pairs (p : ps) = zip (p : ps) (ps ++ [p])
···5355Thus, the solution to the second part is a similar list comprehension with an additional guard:
54565557```haskell
5656-p2 :: [[Integer]] -> Integer
5858+p2 :: [Point] -> Integer
5759p2 poly =
5860 maximum
5961 [ area p p'