AoC/2019/day8/day8.hs
shu 000d745174 Day 8: Golf some more
This is a terrible idea but let’s do it anyway
Refer to previous commits for readable code
2019-12-09 02:55:05 +01:00

17 lines
503 B
Haskell

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