You are viewing a single comment's thread. Return to all comments →
my haskell solution:
import Control.Monad euclidean[x1,y1] [x2,y2] = sqrt $ (x2 - x1)**2 + (y2 - y1)**2 solve n points = sum $ zipWith euclidean pairs (tail pairs ++ [head pairs]) where pairs = map ((\[a, b] -> [read a, read b]) . words) points :: [[Double]] main = do n <- readLn :: IO Int input <- replicateM n getLine print $ solve n input
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 →
my haskell solution: