Day 8: Some shuffling

This commit is contained in:
shu 2019-12-08 07:26:57 +01:00
parent e598a06bc8
commit 8cca2cdc1d

View File

@ -8,11 +8,11 @@ main = do
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
count x = (length . filter (==x))
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
where img = map (head . filter (/='2')) $ transpose xs