You are viewing a single comment's thread. Return to all comments →
Monads are fun
module Main (main) where import Control.Monad main :: IO () main = do pointCount <- read <$> getLine points <- replicateM pointCount (fmap read . head . reads <$> getLine) print $ sum $ zipWith (\(x1, y1) (x2, y2) -> sqrt $ (x2 - x1) ** 2 + (y2 - y1) ** 2) <*> tail $ take (pointCount + 1) $ cycle points
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 →
Monads are fun