Day 8
This commit is contained in:
parent
fa612e9eb6
commit
8413a89bf8
|
@ -0,0 +1,14 @@
|
|||
import Data.List.Split
|
||||
import Data.List
|
||||
|
||||
main = do
|
||||
content <- chunksOf (25*6) <$> head <$> lines <$> readFile "input"
|
||||
print (day8a content)
|
||||
putStrLn (day8b content)
|
||||
|
||||
toLayers xs = snd $ minimum [((length . filter (=='0')) x, x) | x <- xs]
|
||||
day8a xs = let l = toLayers xs in
|
||||
(length $ filter (=='2') l) * (length $ filter (=='1') l)
|
||||
|
||||
day8b xs = intercalate "\n" $ map (map (\x->if x=='0' then ' ' else '•')) $ chunksOf 25 img
|
||||
where img = map (foldr (\x y->if x=='2' then y else x) '2') $ transpose xs
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user