Skip to content

Instantly share code, notes, and snippets.

@jkramer jkramer/temps.hs
Last active Jan 11, 2016

What would you like to do?
CodinGame - Temperatures
import System.IO
import Data.List
import Data.Ord
main = do
hSetBuffering stdout NoBuffering
n <- fmap read getLine
if n == 0
then print 0
else getLine >>= print . head . sortOn abs . reverse . sort . map read . words
-- Pasted from Data.List because it's missing in the (outdated?) version here.
sortOn f = map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.