Created
April 2, 2019 08:36
-
-
Save niinpatel/d84df4cd60f7687f3f9c6a0bb0973fc6 to your computer and use it in GitHub Desktop.
This file contains 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
breakingRecords :: [Int] -> [Int] | |
updateMinMax [maxRec,minRec,max, min] score = | |
[newMaxRec,newMinRec,newMax,newMin] | |
where | |
newMax = if score > max then score else max | |
newMin = if score < min then score else min | |
newMaxRec = if newMax > max then (maxRec + 1) else maxRec | |
newMinRec = if newMin < min then (minRec + 1) else minRec | |
breakingRecords scores = take 2 $ foldl updateMinMax [0,0,head scores, head scores] scores | |
main = interact $ unwords . map show . breakingRecords . map read . tail . words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment