From 99d4c67b7b87c619d0ff1a1772b1c31c9e4aee66 Mon Sep 17 00:00:00 2001 From: shu Date: Sun, 8 Dec 2019 22:00:27 +0100 Subject: [PATCH] Day 8: For the memes --- 2019/day8/day8.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/2019/day8/day8.hs b/2019/day8/day8.hs index 51aa61e..21b37bf 100644 --- a/2019/day8/day8.hs +++ b/2019/day8/day8.hs @@ -9,10 +9,9 @@ main = do print (day8a content) putStrLn (day8b content) -day8a xs = let l = toLayers xs in - count '2' l * count '1' l - where toLayers = minimumBy (comparing (count '0')) - count x = length . filter (==x) +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