Skip to content

Instantly share code, notes, and snippets.

@deepakduggirala
Created October 18, 2018 09:40
Show Gist options
  • Save deepakduggirala/3ba538b5f75131328b6efc8de656f274 to your computer and use it in GitHub Desktop.
Save deepakduggirala/3ba538b5f75131328b6efc8de656f274 to your computer and use it in GitHub Desktop.
module Throwaway where
import Control.Monad
import ConvexHull ( grahamScan
, perimeter
)
import Text.Printf
h :: [Int] -> (Int, Int)
h (x : y : []) = (x, y)
readTuple :: IO (Int, Int)
readTuple = do
s <- getLine
return $ h (map read $ words s)
getPoints :: Int -> IO [(Int, Int)]
getPoints n = replicateM n readTuple
main :: IO ()
main = do
n <- readLn :: IO Int
points <- getPoints n
printf "%.1f\n" $ perimeter . grahamScan $ points
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment