Last active
March 24, 2017 20:04
-
-
Save ilyakooo0/11f226140a09622dee552bb4b7f67407 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import Control.Monad | |
most :: [Int] -> Int | |
most ns = let | |
fs :: [[Int]] | |
fs = group . sort . map (\n -> read [head . show $ n]) $ ns | |
foo acc nn = case (fst acc `compare` length nn, snd acc `compare` head nn) of | |
(GT, _) -> (length nn, head nn) | |
(EQ, GT) -> (length nn, head nn) | |
_ -> acc | |
f :: [[Int]] -> (Int, Int) | |
f nn = foldl foo (length.head $ nn, head.head $ nn) nn | |
in snd $ f fs | |
main = do | |
n <- readLn | |
ns <- replicateM n readLn | |
print $ most ns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment