aboutsummaryrefslogtreecommitdiff
path: root/execs/Day05.hs
blob: 40965ec55bdb8690062fe6741cf0884b54df6200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Main where

import           Data.Char (digitToInt)
import           Data.List (sort)
import           Utils     (binaryToInt)

doValidate = binaryToInt . map readBin
readBin s | s `elem` "FL" = '0'
          | otherwise = '1'

main :: IO ()
main = do
    n <- lines <$> readFile "input/05"
    let valids = sort $ map doValidate n
        ans1 = maximum valids
    print ans1
    print $ (+1) . fst . head . dropWhile ((==1) . uncurry (flip (-))) . (zip <*> tail) $ valids