My solutions to Advent of Code 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

21 lines
358 B

  1. module Main where
  2. main :: IO ()
  3. main = interact solution
  4. windows :: Int -> [a] -> [[a]]
  5. windows _ [] = []
  6. windows n (a:r) = take n (a:r) : windows n r
  7. solution :: String -> String
  8. solution =
  9. show
  10. . sum
  11. . map (fromEnum . (\(a:b:_) -> a < b) )
  12. . init
  13. . windows 2
  14. . map sum
  15. . init . init
  16. . windows 3
  17. . map (read :: String -> Int)
  18. . lines