isEdgeN :: Int -> Board -> Edge -> Bool
isEdgeN n b e@((p1,p2),(q1,q2))
  | h && p1 == 0          = length y == n
  | h && p1 == length b   = length x == n
  | h                     = (length x == n) || (length y == n)
  | p2 == 0               = length y == n
  | p2 == length (head b) = length z == n
  | otherwise             = (length z == n) || (length y == n)
    where h = isHorizontal e
          x  = fst $ (b !! (p1-1)) !! p2
          y  = fst $ (b !! p1) !! p2
          z  = fst $ (b !! p1) !! (p2-1)
isEdgeN :: Int -> Board -> Edge -> Bool
isEdgeN n b e@((p1,p2),(q1,q2))
  | h && p1 == 0          = length y == n
  | h && p1 == length b   = length x == n
  | h                     = (length x == n) || (length y == n)
  | p2 == 0               = length y == n
  | p2 == length (head b) = length z == n
  | otherwise             = (length z == n) || (length y == n)
    where h = isHorizontal e
          x  = fst $ (b !! (p1-1)) !! p2
          y  = fst $ (b !! p1) !! p2
          z  = fst $ (b !! p1) !! (p2-1)
isEdgeN n b e@((p1,p2),(q1,q2))
  | h && p1 == 0          = length y == n
  | h && p1 == length b   = length x == n
  | h                     = (length x == n) || (length y == n)
  | p2 == 0               = length y == n
  | p2 == length (head b) = length z == n
  | otherwise             = (length z == n) || (length y == n)
    where h = isHorizontal e
          x  = fst $ (b !! (p1-1)) !! p2
          y  = fst $ (b !! p1) !! p2
          z  = fst $ (b !! p1) !! (p2-1)