Day 8: We HLint now
This commit is contained in:
parent
8cca2cdc1d
commit
fb1f3e7d04
|
@ -1,18 +1,18 @@
|
|||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
import Data.List.Split
|
||||
import Data.List
|
||||
import Data.Ord
|
||||
|
||||
main = do
|
||||
content <- chunksOf (25*6) <$> head <$> lines <$> readFile "input"
|
||||
content <- (chunksOf (25*6) <$> head) . lines <$> readFile "input"
|
||||
print (day8a content)
|
||||
putStrLn (day8b content)
|
||||
|
||||
|
||||
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))
|
||||
count '2' l * count '1' l
|
||||
where toLayers = minimumBy (comparing (count '0'))
|
||||
count x = length . filter (==x)
|
||||
|
||||
day8b xs = unlines $ map (map (\case '0'->' ';'1'->'•')) $ chunksOf 25 img
|
||||
where img = map (head . filter (/='2')) $ transpose xs
|
||||
|
|
Loading…
Reference in New Issue
Block a user