This commit is contained in:
shu 2019-12-08 07:03:28 +01:00
parent fa612e9eb6
commit 8413a89bf8
2 changed files with 15 additions and 0 deletions

14
2019/day8/day8.hs Normal file
View File

@ -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

1
2019/day8/input Normal file

File diff suppressed because one or more lines are too long