Day 8: For the memes
This commit is contained in:
parent
0b720099a3
commit
99d4c67b7b
|
@ -9,10 +9,9 @@ main = do
|
||||||
print (day8a content)
|
print (day8a content)
|
||||||
putStrLn (day8b content)
|
putStrLn (day8b content)
|
||||||
|
|
||||||
day8a xs = let l = toLayers xs in
|
day8a xs = (*) <$> count '2' <*> count '1'
|
||||||
count '2' l * count '1' l
|
$ minimumBy (comparing $ count '0') xs
|
||||||
where toLayers = minimumBy (comparing (count '0'))
|
where count x = length . filter (==x)
|
||||||
count x = length . filter (==x)
|
|
||||||
|
|
||||||
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
||||||
where img = map (head . filter (/='2')) $ transpose xs
|
where img = map (head . filter (/='2')) $ transpose xs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user