Archivist Anon

me
These are my own solutions to the Advent of Code problems. I’m writing them in Haskell this year. I want to feel big-braned, anon.

archivist/day01.hs
archivist/day01.hs
biggerCount :: [Integer] -> Integer
    biggerCount l = if length(l) == 2
    then bigger (head l) (head (tail l)) 
    else bigger (head l) (head (tail l))  + (biggerCount (tail l))
    
    biggerCount2 :: [Integer] -> Integer
    biggerCount2 l = 
        let a = (l!!0 + l!!1 + l!!2) 
            b = (l!!1 + l!!2 + l!!3) 
        in if length(l) == 4
        then bigger a b 
        else bigger a b + (biggerCount2 (tail l))
    
    bigger :: Integer -> Integer -> Integer
    bigger a b = if a < b then 1 else 0
    
    main = interact nCount
        where nCount input = show (biggerCount2 (map read (lines input) :: [Integer]))
    

Tags: