Sort by

recency

|

9 Discussions

|

  • + 0 comments

    Why can't I download some test cases? when I try I am presented with:

    {"error":"Sorry! testcases are not available for download"}

  • + 0 comments

    This is indeed a subproblem of the Convex Hall Problem. Most of the Convex Hall Algorithm uses a function to determine whether consecutive 3 points are counter-clockwise or not. This problem can be solved by using this counter-clockwise function after sorting points (for example, by polar angle)

  • + 1 comment

    Test case 2 has self intersecting polygon.

    5

    0 0

    2 0

    0 2

    2 2

    1 0

    Expected result is 'No'. really?

  • [deleted]
    + 1 comment

    cool, got to re-use code for the convex hull problem:

    insert :: [Point] -> Point -> [Point]
    insert vs v = case vs of
      (x:y:z:ws) -> case orientation v x y of
        Up -> insert (tail vs) v
        _ -> v : vs
      _ -> v : vs
    
    convexHull :: [Point] -> [Point]
    convexHull = foldl' insert []
    
    convex :: [Point] -> Bool
    convex xs = length xs == length (convexHull xs)
    
    concave = not . convex
    
    solve :: [Point] -> String
    solve xs
      | concave xs = "YES"
      | otherwise  = "NO"
    
  • + 0 comments

    FYI, test #1 seems to have Windows new lines (i.e. \r) which causes ocaml's read_int () to freak out. It would be nice if this could be fixed.