18 lines
488 B
Haskell
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
|