You are viewing a single comment's thread. Return to all comments →
another haskell solution, have a look at it if you want
euclid :: (Integer, Integer) -> (Integer, Integer) -> Double euclid (x1, y1) (x2, y2) = sqrt $ fromIntegral $ (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) perimeter :: [(Integer, Integer)] -> Double perimeter points = sum $ zipWith euclid points $ tail points ++ [head points] tuple :: [a] -> (a, a) tuple [x, y] = (x, y) main = getContents >>= print . perimeter . map (tuple . map read . words) . tail . lines
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Perimeter of a Polygon
You are viewing a single comment's thread. Return to all comments →
another haskell solution, have a look at it if you want