8 text <- readFile "data/advent08.txt"
9 let digits = successfulParse text
10 let layers = chunksOf (imageWidth * imageHeight) digits
12 putStrLn $ part2 layers
17 part1 layers = (count 1 target) * (count 2 target)
18 where target = minimumBy (comparing (count 0)) layers
20 part2 layers = unlines rows
21 where pixelLayers = transpose layers
22 pixels = map firstVisible pixelLayers
23 image = concatMap showPixel pixels
24 rows = chunksOf imageWidth image
26 firstVisible = head . dropWhile (== 2)
29 showPixel 1 = "\x2588"
31 count n = length . filter (== n)
33 successfulParse :: String -> [Int]
34 successfulParse input = map digitToInt input