makeGrid :: [Coord] -> Grid
makeGrid coords =
  let minX = minimum $ map fst coords
      minY = minimum $ map snd coords
      maxX = maximum $ map fst coords
      maxY = maximum $ map snd coords
      b = ((minX, minY), (maxX, maxY))
      withIdx = zip [1..] coords
      points = do
        x <- [minX..maxX]
        y <- [minY..maxY]
        let dists = sortOn snd $ map (\(i, c) -> (i, manhattan (x, y) c)) withIdx
        let v = case dists of
              (a:b:_) -> if snd a == snd b then Nothing else Just (fst a)
              _ -> Nothing
        pure ((x, y), v)
   in Arr.array b points
makeGrid :: [Coord] -> Grid
makeGrid coords =
  let minX = minimum $ map fst coords
      minY = minimum $ map snd coords
      maxX = maximum $ map fst coords
      maxY = maximum $ map snd coords
      b = ((minX, minY), (maxX, maxY))
      withIdx = zip [1..] coords
      points = do
        x <- [minX..maxX]
        y <- [minY..maxY]
        let dists = sortOn snd $ map (\(i, c) -> (i, manhattan (x, y) c)) withIdx
        let v = case dists of
              (a:b:_) -> if snd a == snd b then Nothing else Just (fst a)
              _ -> Nothing
        pure ((x, y), v)
   in Arr.array b points
makeGrid coords =
  let minX = minimum $ map fst coords
      minY = minimum $ map snd coords
      maxX = maximum $ map fst coords
      maxY = maximum $ map snd coords
      b = ((minX, minY), (maxX, maxY))
      withIdx = zip [1..] coords
      points = do
        x <- [minX..maxX]
        y <- [minY..maxY]
        let dists = sortOn snd $ map (\(i, c) -> (i, manhattan (x, y) c)) withIdx
        let v = case dists of
              (a:b:_) -> if snd a == snd b then Nothing else Just (fst a)
              _ -> Nothing
        pure ((x, y), v)
   in Arr.array b points