You are viewing a single comment's thread. Return to all comments →
Here's another Haskell solution:
import Control.Monad main = do n <- readLn ps <- replicateM n $ do [x, y] <- map read . words <$> getLine pure (x, y) print $ sum $ zipWith dist ps (tail (cycle ps)) dist :: (Double, Double) -> (Double, Double) -> Double dist (x1, y1) (x2, y2) = sqrt $ (x1 - x2) ** 2 + (y1 - y2) ** 2
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 →
Here's another Haskell solution: