Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created May 23, 2018 07:06
Show Gist options
  • Save karlbright/3d9129fae2fed2c5ee74ef942fc5225e to your computer and use it in GitHub Desktop.
Save karlbright/3d9129fae2fed2c5ee74ef942fc5225e to your computer and use it in GitHub Desktop.
solve :: [Int] -> [Int]
solve (s:t:a:b:m:_:rest) = [as, os]
where as = length $ filter (\x -> s <= x && x <= t) $ map (\x -> x + a) $ take m rest
os = length $ filter (\x -> s <= x && x <= t) $ map (\x -> x + b) $ drop m rest
main = interact $ unlines . map show . solve . map read . words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment