Mercurial > hg > problem6
changeset 24:1bebd7b76bac draft
optim.hs: sort machines by date when parsing
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Mon, 30 Mar 2015 09:33:53 -0400 |
parents | c555afaeede4 |
children | 5812985ef721 |
files | optim.hs |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/optim.hs +++ b/optim.hs @@ -1,4 +1,5 @@ #!/usr/bin/runhaskell +import Data.List type Number = Int @@ -28,7 +29,8 @@ where (machinelist, nextCase) = splitAt n rest [n, capital, days] = header - machines = map (makeMachine capital) machinelist + machines = sortBy (\m1 m2 -> day m1 `compare` day m2) + $ map (makeMachine capital) machinelist parseInput :: String -> [Case] parseInput input = groupCases (numSplit input)