Compare commits

...

1 Commits

Author SHA1 Message Date
Gaël Depreeuw 12441c70df
Try day 4 4 years ago
  1. 2
      AdventOfCode2020.cabal
  2. 1009
      input/day4
  3. 55
      src/Day4.hs

@ -17,7 +17,7 @@ maintainer: gael@depreeuw.dev
extra-source-files: CHANGELOG.md, README.md
library
exposed-modules: Day1, Day2, Day3
exposed-modules: Day1, Day2, Day3, Day4
-- other-modules:
-- other-extensions:
build-depends: base ^>=4.13.0.0

File diff suppressed because it is too large Load Diff

@ -0,0 +1,55 @@
{-# LANGUAGE OverloadedStrings #-}
module Day4 (day4) where
import Control.Applicative ((<|>))
import Control.Monad (void)
import qualified Data.Attoparsec.Text as P
-- import qualified Data.Text as T
-- import qualified Data.Vector as V
-- import Numeric.Natural (Natural)
type BYR = String
type IYR = String
type EYR = String
type HGT = String
type HCL = String
type ECL = String
type PID = String
type CID = String
data Passport = Passport
{ byr :: BYR,
iyr :: IYR,
eyr :: EYR,
hgt :: HGT,
hcl :: HCL,
ecl :: ECL,
pid :: PID,
cid :: Maybe CID -- Definitely not a hack!
}
deriving (Eq, Show)
parsePassport :: P.Parser Passport
parsePassport = do
-- parse pairs
pairs <- parsePair `P.sepBy` (void P.space <|> P.endOfLine)
undefined
parsePair :: P.Parser (String, String)
parsePair = do
key <- P.count 3 P.letter
_ <- P.char ':'
value <- P.many1 P.anyChar
return (key, value)
day4 :: IO ()
day4 = putStrLn "Day 4"
Loading…
Cancel
Save