AoC/2019/day8/day8.hs

18 lines
488 B
Haskell
Raw Normal View History

2019-12-08 07:14:04 +01:00
{-# LANGUAGE LambdaCase #-}
2019-12-08 08:29:36 +01:00
2019-12-08 07:03:28 +01:00
import Data.List.Split
import Data.List
import Data.Ord
2019-12-08 07:03:28 +01:00
main = do
2019-12-08 08:29:36 +01:00
content <- (chunksOf (25*6) <$> head) . lines <$> readFile "input"
2019-12-08 07:03:28 +01:00
print (day8a content)
putStrLn (day8b content)
2019-12-08 22:00:27 +01:00
day8a xs = (*) <$> count '2' <*> count '1'
$ minimumBy (comparing $ count '0') xs
where count x = length . filter (==x)
2019-12-08 07:03:28 +01:00
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
2019-12-08 07:14:04 +01:00
where img = map (head . filter (/='2')) $ transpose xs