aboutsummaryrefslogtreecommitdiff
path: root/execs/Day05.hs
blob: a47c024d7e51d71409012162ef2ac28ba0a74f2d (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