AoC/2019/day8/day8.hs
2019-12-08 22:00:27 +01:00

18 lines
488 B
Haskell

{-# LANGUAGE LambdaCase #-}
import Data.List.Split
import Data.List
import Data.Ord
main = do
content <- (chunksOf (25*6) <$> head) . lines <$> readFile "input"
print (day8a content)
putStrLn (day8b content)
day8a xs = (*) <$> count '2' <*> count '1'
$ minimumBy (comparing $ count '0') xs
where count x = length . filter (==x)
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
where img = map (head . filter (/='2')) $ transpose xs