19 lines
523 B
Haskell
19 lines
523 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)
|
|
|
|
count x = (length . filter (==x))
|
|
|
|
day8a xs = let l = toLayers xs in
|
|
(count '2' l) * (count '1' l)
|
|
where toLayers xs = minimumBy (comparing (count '0')) xs
|
|
|
|
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
|
where img = map (head . filter (/='2')) $ transpose xs
|